Documentation ¶
Index ¶
- Constants
- func GetRender(w http.ResponseWriter) (*render.Render, error)
- func GetSessionStore(w http.ResponseWriter) (sessions.Store, error)
- func LoggerMiddleware(next http.Handler) http.Handler
- func RecoveryMiddleware(next http.Handler) http.Handler
- func RenderMiddlewareGenerator(rn *render.Render) kitchen.Middleware
- func SessionMiddlewareGenerator(sess sessions.Store) kitchen.Middleware
- func StaticMiddlewareGenerator(dir http.FileSystem, prefix, index string) kitchen.Middleware
- func TimeoutMiddlewareGenerator(to time.Duration) kitchen.Middleware
Constants ¶
const RenderContextKey key = 1
RenderContextKey is the key used to store render inside the context
const SessionContextKey key = 0
SessionContextKey is the key for session store in Context
Variables ¶
This section is empty.
Functions ¶
func GetRender ¶
func GetRender(w http.ResponseWriter) (*render.Render, error)
GetRender is a helper function and returns the render object. Reterns error in case of wrong interface or when the middleware is not used on the request.
func GetSessionStore ¶
func GetSessionStore(w http.ResponseWriter) (sessions.Store, error)
GetSessionStore is for get session from context. make sure the SessionMiddleware is there and you call this after session middleware in chain
func LoggerMiddleware ¶
LoggerMiddleware is a simple middleware to handle logging with logrus
func RecoveryMiddleware ¶
RecoveryMiddleware is a simple middleware for prevent program to panic in unhandled panic from other middleware or request Must add this before any other middleware
func RenderMiddlewareGenerator ¶
func RenderMiddlewareGenerator(rn *render.Render) kitchen.Middleware
RenderMiddlewareGenerator generate a new render middleware for use in kitchen using render package Personally I hate when the framework automatically render a template base on its name. so its not an option here.
func SessionMiddlewareGenerator ¶
func SessionMiddlewareGenerator(sess sessions.Store) kitchen.Middleware
SessionMiddlewareGenerator to create new session midleware.
func StaticMiddlewareGenerator ¶
func StaticMiddlewareGenerator(dir http.FileSystem, prefix, index string) kitchen.Middleware
StaticMiddlewareGenerator create a static middleware function for serve the file from a folder This part is base on negroni static handler
func TimeoutMiddlewareGenerator ¶
func TimeoutMiddlewareGenerator(to time.Duration) kitchen.Middleware
TimeoutMiddlewareGenerator generate a middleware for trigger Done channel on context in every request
Types ¶
This section is empty.