本文整理匯總了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)
}
}