MCPcopy
hub / github.com/gin-gonic/gin / Use

Method Use

gin.go:340–345  ·  view source on GitHub ↗

Use attaches a global middleware to the router. i.e. the middleware attached through Use() will be included in the handlers chain for every single request. Even 404, 405, static files... For example, this is the right place for a logger or error management middleware.

(middleware ...HandlerFunc)

Source from the content-addressed store, hash-verified

338// included in the handlers chain for every single request. Even 404, 405, static files...
339// For example, this is the right place for a logger or error management middleware.
340func (engine *Engine) Use(middleware ...HandlerFunc) IRoutes {
341 engine.RouterGroup.Use(middleware...)
342 engine.rebuild404Handlers()
343 engine.rebuild405Handlers()
344 return engine
345}
346
347// With returns an Engine with the configuration set in the OptionFunc.
348func (engine *Engine) With(opts ...OptionFunc) *Engine {

Callers

nothing calls this directly

Calls 3

rebuild404HandlersMethod · 0.95
rebuild405HandlersMethod · 0.95
UseMethod · 0.65

Tested by

no test coverage detected