Documentation ¶
Overview ¶
Package middleware contains middlewares to aid the development of micro-services
Index ¶
- Constants
- func Apply404(h goji.Handler) goji.Handler
- func ApplyLog(l log.Logger) func(goji.Handler) goji.Handler
- func ApplyRecoverer(l log.Logger) func(goji.Handler) goji.Handler
- func ApplyReqID(h goji.Handler) goji.Handler
- func ApplyStats(h goji.Handler) goji.Handler
- func ApplySubStats(h goji.Handler) goji.Handler
- func CrossDomainRequestAllower(handler goji.Handler) goji.Handler
- func GetReqID(ctx context.Context) string
Constants ¶
const PATKEY = "metrics.pattern"
PATKEY is the key used to store matched patterns in context
const RequestIDKey = "reqID"
Key to use when setting the request ID.
Variables ¶
This section is empty.
Functions ¶
func Apply404 ¶
func Apply404(h goji.Handler) goji.Handler
Apply404 is a middleware that supplies a custom 404 handler TODO: Change it to accept a custom 404 handler
func ApplyRecoverer ¶
func ApplyReqID ¶
func ApplyReqID(h goji.Handler) goji.Handler
ApplyReqID is a middleware that injects a request ID into the context of each request. A request ID is a string of the form "host.example.com/random-0001", where "random" is a base62 random string that uniquely identifies this go process, and where the last number is an atomically incremented request counter.
func ApplyStats ¶
func ApplyStats(h goji.Handler) goji.Handler
ApplyStats wraps a handler to track request counts and response status code counts name-spaced by goji Pattern. It will only include patterns that implement fmt.Stringer. For example, if a request matches the pattern /foo/:bar and returns a 204 status code, it will increment "foo.:bar.request" and "foo.:bar.response.204". In addition it updates a histogram with response latencies
largely influenced by https://github.com/metcalf/saypi
func ApplySubStats ¶
func ApplySubStats(h goji.Handler) goji.Handler
ApplySubStats is a helper for using ApplyStats with nested muxes. It stores the pattern matched in the current mux but does not track any metrics independently. It should be included in every mux except the outer one.
func CrossDomainRequestAllower ¶
func CrossDomainRequestAllower(handler goji.Handler) goji.Handler
Types ¶
This section is empty.