This commit is contained in:
“nishant-sharma”
2021-04-01 12:56:04 +05:30
parent e930b5a136
commit 0fbd842e37
6 changed files with 12 additions and 41 deletions

View File

@@ -27,7 +27,7 @@ func eventsHandler(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "ok")
}
func healthHandler(w http.ResponseWriter, r *http.Request){
func healthHandler(w http.ResponseWriter, r *http.Request) {
if healthyBool {
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, "true")
@@ -37,7 +37,7 @@ func healthHandler(w http.ResponseWriter, r *http.Request){
}
}
func healthToggleHandler(w http.ResponseWriter, r *http.Request){
func healthToggleHandler(w http.ResponseWriter, r *http.Request) {
healthyBool = !healthyBool
io.WriteString(w, "toggled")
}

View File

@@ -29,18 +29,12 @@ func NewServer(port string) (*Server, error) {
return nil, errors.Wrap(err, "failed to create listener")
}
// mux := http.NewServeMux()
// mux.HandleFunc("/events", eventsHandler)
// mux.HandleFunc("/events", eventshandler).Methods("POST")
// mux.HandleFunc("/health", healthHandler).Methods("GET")
// mux.HandleFunc("/health/toggle", healthToggleHandler).Methods("POST")
// mux.HandleFunc("/refresh/schema", refreshSchemaHandler).Methods("POST")
// mux.HandleFunc("/stop", stopHandler).Methods("POST")
router := mux.NewRouter()
router.HandleFunc("/events", eventsHandler).Methods("POST")
router.HandleFunc("/health", healthHandler).Methods("GET")
router.HandleFunc("/health/toggle", healthToggleHandler).Methods("GET")
// router.HandleFunc("/schema/refresh", schemaRefreshHandler).Methods("POST")
// router.HandleFunc("/stop", stopHandler).Methods("POST")
httpServer := &http.Server{Addr: ":" + port, Handler: router}
newServer := &Server{HttpServer: httpServer, Listener: listener}