Documentation ¶
Index ¶
- Variables
- func GetLimitAndOffsetParams(values url.Values) (offset uint64, limit uint64, err error)
- func NewBaseRouter(h BaseHTTPHandler, cfg BaseRouterCfg) (*mux.Router, error)
- func NewBaseServer(router http.Handler, tlsCerts []tls.Certificate, listenAddr string) *http.Server
- type BaseHTTPHandler
- type BaseRouterCfg
- type LoggingResponseWriter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrHandlerConfigIsNotFull will be returned if some handlers Config fields are not populated ErrHandlerConfigIsNotFull = errors.New("some handler Config fields are not populated") // ErrServerConfigIsNotFull will be returned if some servers Config fields are not populated ErrServerConfigIsNotFull = errors.New("some server Config fields are not populated") // ErrRouterConfigIsNotFull will be returned if some servers Config fields are not populated ErrRouterConfigIsNotFull = errors.New("some router Config fields are not populated") )
Functions ¶
func GetLimitAndOffsetParams ¶
GetLimitAndOffsetParams parses offset anf limit from url values
func NewBaseRouter ¶
func NewBaseRouter(h BaseHTTPHandler, cfg BaseRouterCfg) (*mux.Router, error)
NewBaseRouter will return new router with already registered standard endpoints /version.json - to serve service version {cfg.ApiDefinition} - to serve api schema {ProfilerPath} - to serve http profiler
func NewBaseServer ¶ added in v1.0.5
NewBaseServer will cinstruct http server with base configurations. Timeouts|TLS|CORS
Types ¶
type BaseHTTPHandler ¶
type BaseHTTPHandler struct {
Logger logrus.FieldLogger
}
BaseHTTPHandler stores common dependencies and methods for any http api in system.
func (BaseHTTPHandler) GetLimitAndOffset ¶ added in v1.0.3
func (BaseHTTPHandler) GetLimitAndOffset(values url.Values) (offset uint64, limit uint64, err error)
GetLimitAndOffset will return parsed limit and offset from url.Values.
func (BaseHTTPHandler) NewLoggingResponseWriter ¶
func (h BaseHTTPHandler) NewLoggingResponseWriter(w http.ResponseWriter, r *http.Request) LoggingResponseWriter
NewLoggingResponseWriter creates new loggingResponseWriter instance for particular request
type BaseRouterCfg ¶ added in v1.0.3
type BaseRouterCfg struct { ServiceVersion string ProfilerPath string APIDefinition io.Reader APIDefinitionPath string }
BaseRouterCfg stores configs for base router
type LoggingResponseWriter ¶
type LoggingResponseWriter interface { http.ResponseWriter // Log will log request result Log() // WriteHeaderWithErr same as WriteHeader but also will set and Log error with metadata WriteHeaderWithErr(code int, err error) // WriteJSON is a helper that will set corresponding content type, encode your data and Log response WriteJSON(data interface{}, status ...int) // WriteXML is a helper that will set corresponding content type, encode your data and Log response WriteXML(data interface{}, status ...int) }
LoggingResponseWriter describes methods of loggingResponseWriter helper