本文整理汇总了Golang中github.com/gorilla/mux.Route.Handler方法的典型用法代码示例。如果您正苦于以下问题:Golang Route.Handler方法的具体用法?Golang Route.Handler怎么用?Golang Route.Handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gorilla/mux.Route
的用法示例。
在下文中一共展示了Route.Handler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Handler
// HANDLER create route using GorwardRouter values
func (r GowardRouter) Handler(handler http.Handler) Router {
var route *mux.Route
if r.FMiddleware != nil {
handler = bindMiddlewares(handler, r.FMiddleware...)
}
if r.FPath == "/" && r.FParentRouter != nil {
route = r.FParentRouter.NewRoute()
route = route.Path(r.FPrefix)
} else {
route = r.FRouter.NewRoute()
route.Path(r.FPath)
}
if r.FHost != "" {
route = route.Host(r.FHost)
}
if r.Methods != nil {
route = route.Methods(r.FMethods...)
}
route.Handler(handler)
return r
}
示例2: RegisterRoute
func (app *App) RegisterRoute(route *mux.Route, dispatch dispatchFunc, nameRequired nameRequiredFunc, accessRecords customAccessRecordsFunc) {
// TODO(stevvooe): This odd dispatcher/route registration is by-product of
// some limitations in the gorilla/mux router. We are using it to keep
// routing consistent between the client and server, but we may want to
// replace it with manual routing and structure-based dispatch for better
// control over the request execution.
route.Handler(app.dispatcher(dispatch, nameRequired, accessRecords))
}
示例3: wireFrontendBackend
func (server *Server) wireFrontendBackend(routes map[string]types.Route, newRoute *mux.Route, handler http.Handler) {
// strip prefix
var strip bool
for _, route := range routes {
switch route.Rule {
case "PathStrip":
newRoute.Handler(&middlewares.StripPrefix{
Prefix: route.Value,
Handler: handler,
})
strip = true
break
case "PathPrefixStrip":
newRoute.Handler(&middlewares.StripPrefix{
Prefix: route.Value,
Handler: handler,
})
strip = true
break
}
}
if !strip {
newRoute.Handler(handler)
}
}