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

Refactor: move internal package from src/ to internal/ and move src/main.go to cmd/eosio-api-healthcheck/main.go

This commit is contained in:
Henrik Hautakoski 2022-10-27 12:55:44 +02:00
parent c27abb5ed9
commit 6448aeb0f7
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
22 changed files with 19 additions and 17 deletions

View file

@ -1,50 +0,0 @@
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 DebugApiFactory(args ApiArguments) ApiInterface {
return NewDebugApi(args.Url)
}
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, ""
}