Пример #1
0
func provision(r *mux.Router) *mux.Router {

	r.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
		http.Redirect(w, req, "/v1/", http.StatusFound)
	})

	v1Post := r.PathPrefix("/v1").Methods("POST").Subrouter()
	v1Post.Handle("/check-http", webapp.Handler(handler.CheckHttp))

	return r
}
Пример #2
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
}