1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-18 05:00:03 +02:00

src/api/test.go: rename from TestApi to DebugApi

This commit is contained in:
Henrik Hautakoski 2022-10-03 16:15:25 +02:00
parent bda40bf1d5
commit edb063722b
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
2 changed files with 10 additions and 10 deletions

46
src/api/debug.go Normal file
View file

@ -0,0 +1,46 @@
package api
import (
"strings"
"github.com/eosswedenorg-go/haproxy/agentcheck"
)
type DebugApi struct {
response agentcheck.Response
}
func parseResponse(resp string) (agentcheck.Response, error) {
parts := strings.SplitN(resp, "#", 2)
// Status with message
if len(parts) > 1 {
rtype := agentcheck.StatusMessageResponseType(parts[0])
return agentcheck.NewStatusMessageResponse(rtype, parts[1]), nil
}
// Only status.
rtype := agentcheck.StatusResponseType(parts[0])
return agentcheck.NewStatusResponse(rtype), nil
}
func NewDebugApi(response string) DebugApi {
resp, _ := parseResponse(response)
return DebugApi{
response: resp,
}
}
func (d DebugApi) LogInfo() LogParams {
return LogParams{
"type", "Debug",
"response", strings.TrimSpace(d.response.String()),
}
}
func (d DebugApi) Call() (agentcheck.Response, string) {
return d.response, ""
}