Enable the getState function
All checks were successful
Build Pogdark API / Build Pogdark API (pull_request) Successful in 16s
All checks were successful
Build Pogdark API / Build Pogdark API (pull_request) Successful in 16s
This commit is contained in:
parent
f7ddf11f94
commit
0eee8e006d
11
main.go
11
main.go
@ -234,8 +234,7 @@ func fetchAllRecords() (map[string]string, error) {
|
||||
return records, nil
|
||||
}
|
||||
|
||||
/*
|
||||
func getState(w http.ResponseWriter, r *http.Request) {
|
||||
func getState(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Only POST method is allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
@ -251,7 +250,7 @@ func fetchAllRecords() (map[string]string, error) {
|
||||
http.Error(w, "Invalid JSON format", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(request)
|
||||
if request.Id == "" {
|
||||
fmt.Println("Missing or empty Id field")
|
||||
http.Error(w, "Missing or empty Id field", http.StatusBadRequest)
|
||||
@ -286,8 +285,8 @@ func fetchAllRecords() (map[string]string, error) {
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
func setState(w http.ResponseWriter, r *http.Request, s *Server) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Only POST method is allowed", http.StatusMethodNotAllowed)
|
||||
@ -385,7 +384,7 @@ func main() {
|
||||
|
||||
// Register routes on the mux router
|
||||
router.HandleFunc("/ws", server.handleConnections).Methods("GET")
|
||||
//router.HandleFunc("/get", getState).Methods("POST")
|
||||
router.HandleFunc("/get", getState).Methods("POST")
|
||||
router.HandleFunc("/set", func(w http.ResponseWriter, r *http.Request) {
|
||||
setState(w, r, server)
|
||||
}).Methods("POST")
|
||||
|
Loading…
Reference in New Issue
Block a user