Documentation ¶
Index ¶
- Constants
- Variables
- func JSONResponseContextHandler(ctx context.Context, response *goMiddlewareChain.Response, ...) context.Context
- func JSONResponseHandler(response *goMiddlewareChain.Response, writer http.ResponseWriter, ...)
- func LogContextHandler(ctx context.Context, response *goMiddlewareChain.Response, ...) context.Context
- func LogHandler(response *goMiddlewareChain.Response, request *http.Request, ...)
- func MethodNotAllowedResponseHandler(writer http.ResponseWriter, request *http.Request)
- func NotFoundResponseHandler(writer http.ResponseWriter, request *http.Request)
- func PanicHandler(writer http.ResponseWriter, request *http.Request, p interface{})
- func Ping(response *goMiddlewareChain.Response, request *http.Request, ...)
- type LoggerHandler
Constants ¶
const JSONContentType = "application/json"
JSONContentType The default content-type
Variables ¶
var LoggerContextKey = goMiddlewareChain.ContextKey{Key: ""}
LoggerContextKey a key to map the logger
Functions ¶
func JSONResponseContextHandler ¶
func JSONResponseContextHandler(ctx context.Context, response *goMiddlewareChain.Response, writer http.ResponseWriter, request *http.Request, params httprouter.Params) context.Context
JSONResponseContextHandler wrap the response in a standard json structure
func JSONResponseHandler ¶
func JSONResponseHandler(response *goMiddlewareChain.Response, writer http.ResponseWriter, request *http.Request, params httprouter.Params)
JSONResponseHandler wrap the response in a standard json structure
func LogContextHandler ¶
func LogContextHandler(ctx context.Context, response *goMiddlewareChain.Response, request *http.Request, params httprouter.Params) context.Context
LogContextHandler log requests Use this context-handler to log every call to console.
func LogHandler ¶
func LogHandler(response *goMiddlewareChain.Response, request *http.Request, params httprouter.Params)
LogHandler log requests. Use this handler to log every call to console.
func MethodNotAllowedResponseHandler ¶
func MethodNotAllowedResponseHandler(writer http.ResponseWriter, request *http.Request)
MethodNotAllowedResponseHandler handle the default 405 errors with JSONResponseHandler
func NotFoundResponseHandler ¶
func NotFoundResponseHandler(writer http.ResponseWriter, request *http.Request)
NotFoundResponseHandler handle the default 404 errors with JSONResponseHandler
func PanicHandler ¶
func PanicHandler(writer http.ResponseWriter, request *http.Request, p interface{})
PanicHandler handle all crashes with a proper JSONResponseHandler response
func Ping ¶
func Ping(response *goMiddlewareChain.Response, request *http.Request, params httprouter.Params)
Ping route should just respond with pong
Types ¶
type LoggerHandler ¶
LoggerHandler holds the logger-instance
func NewLoggerHandler ¶
func NewLoggerHandler(writer *syslog.Writer) *LoggerHandler
NewLoggerHandler creates a new LoggerHandler
func (*LoggerHandler) Handle ¶
func (handler *LoggerHandler) Handle(ctx context.Context, response *goMiddlewareChain.Response, request *http.Request, params httprouter.Params) context.Context
Handle is the handler for the LoggerHandler