- if r.Method != "POST" {
- http.Error(w, "Method is not supported.", http.StatusMethodNotAllowed)
- return
- }
+func NewRouter(jm jobs.JobsManager) *mux.Router {
+ callbackHandler := NewProducerCallbackHandler(jm)
+ r := mux.NewRouter()
+ r.HandleFunc(StatusPath, statusHandler).Methods(http.MethodGet).Name("status")
+ 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
+}
+
+func statusHandler(w http.ResponseWriter, r *http.Request) {
+ // Just respond OK to show the server is alive for now. Might be extended later.
+}