templates

package
v0.0.0-...-aacc5d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const JSONContentType = "application/json"

JSONContentType The default content-type

Variables

View Source
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

type LoggerHandler struct {
	Writer *syslog.Writer
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL