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


Golang Router.NotFoundHandler方法代碼示例

本文整理匯總了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")
}
開發者ID:trwalker,項目名稱:marvel-go,代碼行數:8,代碼來源:route_config.go

示例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()))
}
開發者ID:aosen,項目名稱:novel,代碼行數:15,代碼來源:routers.go

示例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}
}
開發者ID:tamcgoey,項目名稱:oaked.v1,代碼行數:16,代碼來源:router.go

示例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)
}
開發者ID:MrDustpan,項目名稱:go-samples,代碼行數:17,代碼來源:routes.go

示例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
}
開發者ID:spambarrier,項目名稱:anaLog,代碼行數:21,代碼來源:router.go

示例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)
}
開發者ID:tomzhang,項目名稱:metricproxy,代碼行數:5,代碼來源:signalfxlistener.go


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