Documentation
¶
Overview ¶
Package steward provides a drop in way of adding a status endpoint to your services
Example (CustomResponse) ¶
ExampleCustomResponse demonstrates how to configure a custom response
package main
import (
"net"
"net/http"
. "github.com/gomicro/steward"
)
// StatusResponse is the data for the status endpoint to display
type StatusResponse struct {
Application string `json:"app"`
Version string `json:"version"`
BuildTime string `json:"buildTime"`
}
// ExampleCustomResponse demonstrates how to configure a custom response
func main() {
SetStatusResponse(&StatusResponse{Application: "Foo", Version: "1.0.0", BuildTime: "Today"})
go http.ListenAndServe(net.JoinHostPort("0.0.0.0", "8000"), nil)
select {}
}
Output:
Example (Dropin) ¶
ExampleDropin demonstrates how to start a service with steward automatically injecting a status endpoint
package main
import (
"net"
"net/http"
_ "github.com/gomicro/steward"
)
var (
host = "0.0.0.0"
port = "8000"
)
// ExampleDropin demonstrates how to start a service with steward automatically injecting a status endpoint
func main() {
go http.ListenAndServe(net.JoinHostPort(host, port), nil)
select {}
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleStatus ¶
func HandleStatus(w http.ResponseWriter, req *http.Request)
HandleStatus implements the go http handler interface to display specified status details
func SetStatusEndpoint ¶
func SetStatusEndpoint(e string)
SetStatusEndpoint overrides the default endpoint with desired value
func SetStatusResponse ¶
func SetStatusResponse(v interface{})
SetStatusResponse overrides the default response payload for the status endpoint
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.
