mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-18 05:00:03 +02:00
Fix code formatting
This commit is contained in:
parent
b0e5b455ca
commit
adb1ad3c6d
21 changed files with 884 additions and 950 deletions
|
|
@ -1,50 +1,48 @@
|
|||
|
||||
package api
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
||||
"strings"
|
||||
|
||||
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
||||
)
|
||||
|
||||
type DebugApi struct {
|
||||
response agentcheck.Response
|
||||
response agentcheck.Response
|
||||
}
|
||||
|
||||
func parseResponse(resp string) (agentcheck.Response, error) {
|
||||
parts := strings.SplitN(resp, "#", 2)
|
||||
|
||||
parts := strings.SplitN(resp, "#", 2)
|
||||
// Status with message
|
||||
if len(parts) > 1 {
|
||||
rtype := agentcheck.StatusMessageResponseType(parts[0])
|
||||
return agentcheck.NewStatusMessageResponse(rtype, parts[1]), nil
|
||||
}
|
||||
|
||||
// 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
|
||||
// Only status.
|
||||
rtype := agentcheck.StatusResponseType(parts[0])
|
||||
return agentcheck.NewStatusResponse(rtype), nil
|
||||
}
|
||||
|
||||
func DebugApiFactory(args ApiArguments) ApiInterface {
|
||||
return NewDebugApi(args.Url)
|
||||
return NewDebugApi(args.Url)
|
||||
}
|
||||
|
||||
func NewDebugApi(response string) DebugApi {
|
||||
resp, _ := parseResponse(response)
|
||||
|
||||
resp, _ := parseResponse(response)
|
||||
|
||||
return DebugApi{
|
||||
response: resp,
|
||||
}
|
||||
return DebugApi{
|
||||
response: resp,
|
||||
}
|
||||
}
|
||||
|
||||
func (d DebugApi) LogInfo() LogParams {
|
||||
return LogParams{
|
||||
"type", "Debug",
|
||||
"response", strings.TrimSpace(d.response.String()),
|
||||
}
|
||||
return LogParams{
|
||||
"type", "Debug",
|
||||
"response", strings.TrimSpace(d.response.String()),
|
||||
}
|
||||
}
|
||||
|
||||
func (d DebugApi) Call() (agentcheck.Response, string) {
|
||||
return d.response, ""
|
||||
return d.response, ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue