本文整理匯總了Golang中github.com/gorilla/mux.Router.Host方法的典型用法代碼示例。如果您正苦於以下問題:Golang Router.Host方法的具體用法?Golang Router.Host怎麽用?Golang Router.Host使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gorilla/mux.Router
的用法示例。
在下文中一共展示了Router.Host方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: loadAPIEndpoints
// Set up default Tyk control API endpoints - these are global, so need to be added first
func loadAPIEndpoints(Muxer *mux.Router) {
var ApiMuxer *mux.Router
ApiMuxer = Muxer
if config.EnableAPISegregation {
if config.ControlAPIHostname != "" {
ApiMuxer = Muxer.Host(config.ControlAPIHostname).Subrouter()
}
}
// Add a root message to check all is OK
ApiMuxer.HandleFunc("/hello", pingTest)
// set up main API handlers
ApiMuxer.HandleFunc("/tyk/reload/group", CheckIsAPIOwner(groupResetHandler))
ApiMuxer.HandleFunc("/tyk/reload/", CheckIsAPIOwner(resetHandler))
if !IsRPCMode() {
ApiMuxer.HandleFunc("/tyk/org/keys/"+"{rest:.*}", CheckIsAPIOwner(orgHandler))
ApiMuxer.HandleFunc("/tyk/keys/policy/"+"{rest:.*}", CheckIsAPIOwner(policyUpdateHandler))
ApiMuxer.HandleFunc("/tyk/keys/create", CheckIsAPIOwner(createKeyHandler))
ApiMuxer.HandleFunc("/tyk/apis/"+"{rest:.*}", CheckIsAPIOwner(apiHandler))
ApiMuxer.HandleFunc("/tyk/health/", CheckIsAPIOwner(healthCheckhandler))
ApiMuxer.HandleFunc("/tyk/oauth/clients/create", CheckIsAPIOwner(createOauthClient))
ApiMuxer.HandleFunc("/tyk/oauth/refresh/"+"{rest:.*}", CheckIsAPIOwner(invalidateOauthRefresh))
} else {
log.WithFields(logrus.Fields{
"prefix": "main",
}).Info("Node is slaved, REST API minimised")
}
ApiMuxer.HandleFunc("/tyk/keys/"+"{rest:.*}", CheckIsAPIOwner(keyHandler))
ApiMuxer.HandleFunc("/tyk/oauth/clients/"+"{rest:.*}", CheckIsAPIOwner(oAuthClientHandler))
}
示例2: setupSubway
func setupSubway(router *mux.Router, sconfig *config, www, host string) {
subwayAPI := subway.NewSubwayAPI(sconfig.SubwayKey)
// add subway subdomain to webserver
subwayRouter := router.Host(host).Subrouter()
// add subways's API to the subdomain
subwayAPIRouter := subwayRouter.PathPrefix(subwayAPI.UrlPrefix()).Subrouter()
subwayAPI.Handle(subwayAPIRouter)
// add subway UI to to the subdomain...web we have one
subwayRouter.PathPrefix("/").Handler(http.FileServer(http.Dir(www)))
}
示例3: loadAPIEndpoints
// Set up default Tyk control API endpoints - these are global, so need to be added first
func loadAPIEndpoints(Muxer *mux.Router) {
log.WithFields(logrus.Fields{
"prefix": "main",
}).Info("Initialising Tyk REST API Endpoints")
var ApiMuxer *mux.Router
ApiMuxer = Muxer
if config.EnableAPISegregation {
if config.ControlAPIHostname != "" {
ApiMuxer = Muxer.Host(config.ControlAPIHostname).Subrouter()
}
}
// set up main API handlers
ApiMuxer.HandleFunc("/tyk/reload/group", CheckIsAPIOwner(InstrumentationMW(groupResetHandler)))
ApiMuxer.HandleFunc("/tyk/reload/", CheckIsAPIOwner(InstrumentationMW(resetHandler)))
if !IsRPCMode() {
ApiMuxer.HandleFunc("/tyk/org/keys/"+"{rest:.*}", CheckIsAPIOwner(InstrumentationMW(orgHandler)))
ApiMuxer.HandleFunc("/tyk/keys/policy/"+"{rest:.*}", CheckIsAPIOwner(InstrumentationMW(policyUpdateHandler)))
ApiMuxer.HandleFunc("/tyk/keys/create", CheckIsAPIOwner(InstrumentationMW(createKeyHandler)))
ApiMuxer.HandleFunc("/tyk/apis/"+"{rest:.*}", CheckIsAPIOwner(InstrumentationMW(apiHandler)))
ApiMuxer.HandleFunc("/tyk/health/", CheckIsAPIOwner(InstrumentationMW(healthCheckhandler)))
ApiMuxer.HandleFunc("/tyk/oauth/clients/create", CheckIsAPIOwner(InstrumentationMW(createOauthClient)))
ApiMuxer.HandleFunc("/tyk/oauth/refresh/"+"{rest:.*}", CheckIsAPIOwner(InstrumentationMW(invalidateOauthRefresh)))
ApiMuxer.HandleFunc("/tyk/cache/"+"{rest:.*}", CheckIsAPIOwner(InstrumentationMW(invalidateCacheHandler)))
} else {
log.WithFields(logrus.Fields{
"prefix": "main",
}).Info("Node is slaved, REST API minimised")
}
ApiMuxer.HandleFunc("/tyk/keys/"+"{rest:.*}", CheckIsAPIOwner(InstrumentationMW(keyHandler)))
ApiMuxer.HandleFunc("/tyk/oauth/clients/"+"{rest:.*}", CheckIsAPIOwner(InstrumentationMW(oAuthClientHandler)))
log.WithFields(logrus.Fields{
"prefix": "main",
}).Debug("Loaded API Endpoints")
}
示例4: setupJP
func setupJP(router *mux.Router, host string) {
srouter := router.Host(host).Subrouter()
srouter.PathPrefix("/").Handler(http.FileServer(http.Dir("/opt/jp/www/jprbnsn")))
}
示例5: setupWG4GL
func setupWG4GL(router *mux.Router, host string) {
wgRouter := router.Host(host).Subrouter()
wgRouter.PathPrefix("/").Handler(http.FileServer(http.Dir("/opt/jp/www/wg4gl")))
}
示例6: setupColin
func setupColin(router *mux.Router, host string) {
wgRouter := router.Host(host).Subrouter()
wgRouter.PathPrefix("/").Handler(http.FileServer(http.Dir("/opt/jp/www/colinjhiggins")))
}