- if r.Method != "POST" {
- http.Error(w, "Method is not supported.", http.StatusMethodNotAllowed)
- return
- }
+func NewRouter(jm jobs.JobsManager, hcf func(http.ResponseWriter, *http.Request)) *mux.Router {
+ callbackHandler := NewProducerCallbackHandler(jm)
+ r := mux.NewRouter()
+ r.HandleFunc(HealthCheckPath, hcf).Methods(http.MethodGet).Name("health_check")
+ r.HandleFunc(AddJobPath, callbackHandler.addInfoJobHandler).Methods(http.MethodPost).Name("add")
+ r.HandleFunc(deleteJobPath, callbackHandler.deleteInfoJobHandler).Methods(http.MethodDelete).Name("delete")
+ r.HandleFunc(logAdminPath, callbackHandler.setLogLevel).Methods(http.MethodPut).Name("setLogLevel")
+ r.NotFoundHandler = ¬FoundHandler{}
+ r.MethodNotAllowedHandler = &methodNotAllowedHandler{}
+ return r
+}