diff --git a/api/config.go b/api/config.go index 0d2b5ea..ba40a44 100644 --- a/api/config.go +++ b/api/config.go @@ -64,7 +64,7 @@ func registerConfig() error { err = config.Register(&config.Option{ Name: "API Keys", Key: CfgAPIKeys, - Description: "Defined API Keys.", + Description: "Define API keys for priviledged access to the API. Every entry is a separate API key with respective permissions. Format is `?read=&write=`. Permissions are `anyone`, `user` and `admin`, and may be omitted.", OptType: config.OptTypeStringArray, ExpertiseLevel: config.ExpertiseLevelDeveloper, ReleaseLevel: config.ReleaseLevelStable, diff --git a/api/endpoints.go b/api/endpoints.go index 509715d..2c92b97 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -41,6 +41,7 @@ type Endpoint struct { HandlerFunc http.HandlerFunc `json:"-"` // Documentation Metadata. + Name string Description string Parameters []Parameter diff --git a/api/endpoints_debug.go b/api/endpoints_debug.go index e736fd9..9e81dae 100644 --- a/api/endpoints_debug.go +++ b/api/endpoints_debug.go @@ -11,6 +11,16 @@ import ( ) func registerDebugEndpoints() error { + if err := RegisterEndpoint(Endpoint{ + Path: "ping", + Read: PermitAnyone, + ActionFunc: ping, + Name: "Ping", + Description: "Pong.", + }); err != nil { + return err + } + if err := RegisterEndpoint(Endpoint{ Path: "debug/stack", Read: PermitAnyone, @@ -50,6 +60,11 @@ func registerDebugEndpoints() error { return nil } +// ping responds with pong. +func ping(ar *Request) (msg string, err error) { + return "Pong.", nil +} + // getStack returns the current goroutine stack. func getStack(_ *Request) (data []byte, err error) { buf := &bytes.Buffer{} diff --git a/api/endpoints_meta.go b/api/endpoints_meta.go index b0f0081..0cf4189 100644 --- a/api/endpoints_meta.go +++ b/api/endpoints_meta.go @@ -7,16 +7,6 @@ import ( ) func registerMetaEndpoints() error { - if err := RegisterEndpoint(Endpoint{ - Path: "ping", - Read: PermitAnyone, - ActionFunc: ping, - Name: "Ping", - Description: "Pong.", - }); err != nil { - return err - } - if err := RegisterEndpoint(Endpoint{ Path: "endpoints", Read: PermitAnyone, @@ -94,10 +84,6 @@ func permissions(ar *Request) (i interface{}, err error) { }, nil } -func ping(ar *Request) (msg string, err error) { - return "Pong.", nil -} - func authBearer(w http.ResponseWriter, r *http.Request) { // Check if authenticated by checking read permission. ar := GetAPIRequest(r)