當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Route.Handler方法代碼示例

本文整理匯總了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
}
開發者ID:gorward,項目名稱:mux,代碼行數:26,代碼來源:mux.go

示例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))
}
開發者ID:juanluisvaladas,項目名稱:origin,代碼行數:8,代碼來源:app.go

示例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)
	}
}
開發者ID:tayzlor,項目名稱:traefik,代碼行數:25,代碼來源:server.go


注:本文中的github.com/gorilla/mux.Route.Handler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。