41 lines
730 B
Go
41 lines
730 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"net/http"
|
||
|
|
||
|
"codeberg.org/vlbeaudoin/voki/v3"
|
||
|
)
|
||
|
|
||
|
var _ voki.Requester[HealthGETResponse] = HealthGETRequest{}
|
||
|
|
||
|
type HealthGETRequest struct{}
|
||
|
|
||
|
func (request HealthGETRequest) Complete() bool { return true }
|
||
|
|
||
|
func (request HealthGETRequest) Request(v *voki.Voki) (response HealthGETResponse, err error) {
|
||
|
if !request.Complete() {
|
||
|
err = fmt.Errorf("Incomplete HealthGET request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
statusCode, body, err := v.CallAndParse(
|
||
|
http.MethodGet,
|
||
|
"/api/health/",
|
||
|
nil,
|
||
|
true,
|
||
|
)
|
||
|
if err != nil {
|
||
|
err = fmt.Errorf("%d: %s", statusCode, err)
|
||
|
return
|
||
|
}
|
||
|
response.SetStatusCode(statusCode)
|
||
|
|
||
|
if err = json.Unmarshal(body, &response); err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|