package main import ( "isl-api/Controllers" "log" "net/http" ) func main() { mux := http.NewServeMux() mux.HandleFunc("/", index) Controllers.SetPowerItemEndpoints(mux, "powerItem") err := http.ListenAndServe(":3000", mux) log.Fatal(err) } func index(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { http.NotFound(w, r) return } // Common code for all requests can go here... switch r.Method { case http.MethodGet: // Handle the GET request... case http.MethodPost: // Handle the POST request... case http.MethodOptions: w.Header().Set("Allow", "GET, POST, OPTIONS") w.WriteHeader(http.StatusNoContent) default: w.Header().Set("Allow", "GET, POST, OPTIONS") http.Error(w, "method not allowed", http.StatusMethodNotAllowed) } }