本文整理匯總了Golang中github.com/gorilla/mux.Router.NotFoundHandler方法的典型用法代碼示例。如果您正苦於以下問題:Golang Router.NotFoundHandler方法的具體用法?Golang Router.NotFoundHandler怎麽用?Golang Router.NotFoundHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gorilla/mux.Router
的用法示例。
在下文中一共展示了Router.NotFoundHandler方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegisterRoutes
func RegisterRoutes(apiRouter *mux.Router) {
apiRouter.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
})
apiRouter.HandleFunc("/v1/characters", controllers.CharacterListControllerInstance.Get).Methods("GET")
apiRouter.HandleFunc("/v1/characters/{characterName}", controllers.CharacterControllerInstance.Get).Methods("GET")
}
示例2: Register
func Register(web *utils.Web, r *mux.Router) {
// Bind to a port and pass our router in
r.HandleFunc("/taglist/", web.Go(&controllers.TaglistHandler{}))
r.HandleFunc("/novellist/", web.Go(&controllers.NovelListHandler{}))
r.HandleFunc("/novelintroduction/", web.Go(&controllers.NovelIntroductionHandler{}))
r.HandleFunc("/novelchapter/", web.Go(&controllers.NovelChapterHandler{}))
r.HandleFunc("/novelcontent/", web.Go(&controllers.NovelContentHandler{}))
r.HandleFunc("/novelpv/", web.Go(&controllers.NovelPVHandler{}))
r.HandleFunc("/novelcollect/", web.Go(&controllers.NovelCollectHandler{}))
r.HandleFunc("/novelsearch/", web.Go(&controllers.NovelSearchHandler{}))
r.HandleFunc("/novelrank/", web.Go(&controllers.RankHandler{}))
r.HandleFunc("/noveldownload/", web.Go(&controllers.DownloadHandler{}))
r.HandleFunc("/novelrecommend/", web.Go(&controllers.NovelRecommendHandler{}))
r.NotFoundHandler = http.HandlerFunc(web.Go(controllers.NewNotFoundHandler()))
}
示例3: Router
// Router - Responsible for all routing
func Router(mx *mux.Router, env *config.Env) {
// Twilio
mx.Handle("/twilio/messages", Handler{env, twilio.HandleCreateMessage}).Methods("POST")
// Visits
mx.Handle("/visits", Handler{env, visits.HandleIndex}).Methods("GET")
mx.Handle("/visits", Handler{env, visits.HandleCreate}).Methods("POST")
mx.Handle("/visits/{id}", Handler{env, visits.HandleGet}).Methods("GET")
mx.Handle("/visits/{id}/messages", Handler{env, visits.HandleVisitMessagesIndex}).Methods("GET")
mx.Handle("/visits/{id}/messages", Handler{env, visits.HandleVisitMessagesCreate}).Methods("POST")
mx.Handle("/visits/{id}/surveys", Handler{env, visits.HandleVisitSurveysCreate}).Methods("POST")
mx.NotFoundHandler = Handler{env, handleNotFoundRoute}
}
示例4: Register
// Register maps all routes to the appropriate handler
func Register(router *mux.Router, t *template.Template) {
home := controllers.NewHome(t)
router.HandleFunc("/", home.Index)
router.HandleFunc("/about", home.About)
router.NotFoundHandler = http.HandlerFunc(home.NotFound)
account := controllers.NewAccount(t)
router.HandleFunc("/login", account.Login)
router.Methods("POST").Path("/signin").HandlerFunc(account.Signin)
admin := controllers.NewAdmin(t)
router.Handle("/admin", AuthHandler(admin.Index))
static := http.StripPrefix("/static/", http.FileServer(http.Dir("./static/")))
router.PathPrefix("/static/").Handler(static)
}
示例5: provision
func provision(r *mux.Router) *mux.Router {
r.NotFoundHandler = webapp.Handler(handler.NotFound)
r.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req, "/v1/", http.StatusFound)
})
v1 := r.PathPrefix("/v1").Subrouter()
v1Push := v1.PathPrefix("/push").Subrouter()
v1Push.Handle("/recurring/{task}", webapp.Handler(handler.PushRecurringBegin)).Methods("POST")
v1Push.Handle("/recurring/{task}/{identifier}/{state}", webapp.Handler(handler.PushRecurringEnd)).Methods("PUT")
v1Push.Handle("/recurring/analyze", webapp.Handler(handler.AnalyzeRecurring)).Methods("GET")
v1Nagios := v1.PathPrefix("/nagios").Subrouter()
v1Nagios.Handle("/status", webapp.Handler(handler.NagiosStatus)).Methods("GET")
v1Nagios.Handle("/reset", webapp.Handler(handler.NagiosReset)).Methods("GET", "POST")
return r
}
示例6: setupNotFoundHandler
func setupNotFoundHandler(r *mux.Router, ctx context.Context, name string) stats.Keeper {
metricTracking := web.RequestCounter{}
r.NotFoundHandler = web.NewHandler(ctx, web.FromHTTP(http.NotFoundHandler())).Add(web.NextHTTP(metricTracking.ServeHTTP))
return stats.ToKeeperMany(map[string]string{"location": "listener", "name": name, "type": "http404"}, &metricTracking)
}