Exemplo n.º 1
0
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")
}
Exemplo n.º 2
0
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()))
}
Exemplo n.º 3
0
// 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}
}
Exemplo n.º 4
0
// 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)
}
Exemplo n.º 5
0
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
}
Exemplo n.º 6
0
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)
}