Documentation
¶
Overview ¶
Package server provides an http server.
Index ¶
- func Response(ctx context.Context, w http.ResponseWriter, err error)
- type Option
- func WithAddr(addr string) Option
- func WithCORS(c *cors.Options) Option
- func WithLogger(logger *zerolog.Logger) Option
- func WithReadTimeout(timeout time.Duration) Option
- func WithShutdownTimeout(timeout time.Duration) Option
- func WithTLS(cfg *tls.Config) Option
- func WithWriteTimeout(timeout time.Duration) Option
- type ResponseError
- type Server
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option provides options for configuring the creation of a http server.
func WithLogger ¶
WithServerLogger provides a logger to the server.
func WithReadTimeout ¶ added in v0.0.15
WithReadTimeout sets the http server read timeout.
func WithShutdownTimeout ¶
WithShutdownTimeout sets the timout for shutting down the server.
func WithWriteTimeout ¶ added in v0.0.15
WithWriteTimeout sets the http server read timeout.
type ResponseError ¶
type ResponseError struct {
// Status is the http status code applicable to this problem.
Status int `json:"status"`
// Detail is a human-readable explanation specific to this occurrence of
// the problem.
Detail string `json:"detail,omitempty"`
}
ResponseError provides additional information about problems encounted while performing an operation. See: https://jsonapi.org/format/#error-objects
swagger:response ResponseError
func (ResponseError) Error ¶
func (e ResponseError) Error() string
Error translates the error to a string.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an HTTP server.
func (*Server) Middleware ¶
func (s *Server) Middleware(mw ...mux.MiddlewareFunc)
Middleware installs the given middleware with the router.
type Service ¶
type Service interface {
// Register will register this service with the given router.
Register(router *mux.Router)
// Name provides the name of the service.
Name() string
// Shutdown allows the service to stop any long running background processes it
// may have.
Shutdown()
}
Service defines the methods required by the Server to register with the service with the router.