本文整理汇总了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")))
}