Documentation
¶
Overview ¶
Package mux is a wrapper over goji.Mux
It adds a predefined list of middlewares to muxes and sub-muxes that would be created via the New() and Sub() functions ¶
e.g. usage
acslog := log.NewJSONLogger(conf.Log.Access) errlog := log.NewJSONLogger(conf.Log.Err) mux.Init(acslog, errlog)
To set custom middleware like logger, 404, metrics and 404 handlers to all muxes, use
acslog := log.NewJSONLogger(conf.Log.Access) errlog := log.NewJSONLogger(conf.Log.Err) mux.SetLogs(acslog, errlog) mux.SetSubMware( middleware.ApplySubStats, middleware.Apply404) mux.SetMware( middleware.ApplyLog(acsslog), middleware.Apply404, middleware.ApplyStats, middleware.ApplyReqID)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init initializes the mux package. It initializes the middlewares to be used by Muxes & SubMuxes and sets the loggers. An application can overwrite the middlewares by calling SetMware & SetSubMware
func SetMware ¶
func SetMware(m ...func(goji.Handler) goji.Handler)
SetMware sets the middlewares to be used for all muxes
func SetSubMware ¶
func SetSubMware(m ...func(goji.Handler) goji.Handler)
SetSubMware sets the middlewares to be used for all sub-muxes
Types ¶
type Mux ¶
type Mux struct {
*goji.Mux
}
Mux is a wrapper over Goji's mux
func New ¶
func New() *Mux
New is a wrapper over goji.NewMux(). It adds the pre-defined list of middlewares to the mux
func Sub ¶
func Sub() *Mux
Sub is a wrapper over goji.SubMux(). It adds the pre-defined list of middlewares to the submux
func (*Mux) Delete ¶
func (m *Mux) Delete(pattern string, h func(context.Context, http.ResponseWriter, *http.Request) error)
Delete dispatches to the given handler when the pattern matches and the HTTP method is DELETE.
func (*Mux) Get ¶
func (m *Mux) Get(pattern string, h func(context.Context, http.ResponseWriter, *http.Request) error)
Get dispatches to the given handler when the pattern matches and the HTTP method is GET.
func (*Mux) Head ¶
func (m *Mux) Head(pattern string, h func(context.Context, http.ResponseWriter, *http.Request) error)
Head dispatches to the given handler when the pattern matches and the HTTP method is HEAD.
func (*Mux) Options ¶
func (m *Mux) Options(pattern string, h func(context.Context, http.ResponseWriter, *http.Request) error)
Options dispatches to the given handler when the pattern matches and the HTTP method is OPTIONS.
func (*Mux) Patch ¶
func (m *Mux) Patch(pattern string, h func(context.Context, http.ResponseWriter, *http.Request) error)
Patch dispatches to the given handler when the pattern matches and the HTTP method is PATCH.