Documentation ¶
Index ¶
- Variables
- func Cors(c CorsConfig) *cors.Cors
- func HandleVersionV1(router chi.Router)
- func JsonLogRecoverer(next http.Handler) http.Handler
- func WaitForTermination()
- func WaitForTerminationCallback(callback func(signal string))
- func WriteErrorResponse(w http.ResponseWriter, status int, err error)
- func WriteErrorResponseLog(w http.ResponseWriter, status int, msg string, err error)
- func WriteMessageResponse(w http.ResponseWriter, status int, msg string)
- func WriteMessageResponseLog(w http.ResponseWriter, status int, msg string)
- type ConfigLoader
- type ConfigLoaderImpl
- type CorsConfig
- type ErrorResponse
- type Probe
- type ProbeService
Constants ¶
This section is empty.
Variables ¶
var Version string
can be set from outside within go build command -ldflags="-X github.com/fratschi/go-microservice/internal/std.Version=${SERVICE_VERSION}"
Functions ¶
func Cors ¶
func Cors(c CorsConfig) *cors.Cors
func HandleVersionV1 ¶
func JsonLogRecoverer ¶
JsonLogRecoverer logs the panic (and a backtrace) as json and returns an HTTP 500 (Internal Server Error) status if possible.
func WaitForTermination ¶
func WaitForTermination()
WaitForTermination waits for the TERM or INT signal to stop the services.
func WaitForTerminationCallback ¶
func WaitForTerminationCallback(callback func(signal string))
WaitForTerminationCallback waits for the TERM or INT signal to stop the services. If signal is received, the callback is executed
func WriteErrorResponse ¶
func WriteErrorResponse(w http.ResponseWriter, status int, err error)
func WriteErrorResponseLog ¶
func WriteErrorResponseLog(w http.ResponseWriter, status int, msg string, err error)
func WriteMessageResponse ¶
func WriteMessageResponse(w http.ResponseWriter, status int, msg string)
func WriteMessageResponseLog ¶
func WriteMessageResponseLog(w http.ResponseWriter, status int, msg string)
Types ¶
type ConfigLoader ¶
type ConfigLoader interface { LoadConfig(cfg interface{}) error LoadConfigData([]byte, interface{}) error Paths(p ...string) ConfigLoader File(f string) ConfigLoader }
func NewConfigLoader ¶
func NewConfigLoader() ConfigLoader
type ConfigLoaderImpl ¶
type ConfigLoaderImpl struct {
// contains filtered or unexported fields
}
func (ConfigLoaderImpl) File ¶
func (c ConfigLoaderImpl) File(f string) ConfigLoader
func (ConfigLoaderImpl) LoadConfig ¶
func (c ConfigLoaderImpl) LoadConfig(cfg interface{}) error
func (ConfigLoaderImpl) LoadConfigData ¶
func (c ConfigLoaderImpl) LoadConfigData(data []byte, cfg interface{}) error
func (ConfigLoaderImpl) Paths ¶
func (c ConfigLoaderImpl) Paths(p ...string) ConfigLoader
type CorsConfig ¶
type ErrorResponse ¶
type ErrorResponse struct { // Code is a short, machine-readable identifier that indicates the type of error that occurred. Code string `json:"code"` // Message provides more human-readable information about what went wrong. Message string `json:"message"` }
ErrorResponse is a Go structure that encapsulates error information for the rest interfaces.
func (ErrorResponse) Bytes ¶
func (e ErrorResponse) Bytes() []byte
Bytes returns the json information of the error as bytes
type ProbeService ¶
func NewProbeService ¶
func NewProbeService() *ProbeService
NewProbeService creates a new probe services.
func (*ProbeService) AddLive ¶
func (p *ProbeService) AddLive(probe Probe)
AddLive adds a liveness probe to the list of executed probes when the endpoint /live is called
func (*ProbeService) AddReady ¶
func (p *ProbeService) AddReady(probe Probe)
AddReady adds a readiness probe to the list of executed probes when the endpoint /ready is called
func (*ProbeService) AddStart ¶
func (p *ProbeService) AddStart(probe Probe)
AddStart adds a start probe to the list of executed probes when the endpoint /start is called
func (*ProbeService) HandleProbes ¶
func (p *ProbeService) HandleProbes(router chi.Router)
HandleProbes configures the router for the three probes endpoints.