Original post

I am trying to set a variable based on the value in the curl -X POST http://127.0.0.1:8080/api/var=1.0. Integer and negative numbers are working but I cannot make the decimal values to be passed, it always returns the 404 code. Can you help me? What’s wrong here?

func handlerVar(w http.ResponseWriter, r *http.Request) {
        vars := mux.Vars(r)
        log.Println("var:", vars["var"])

        w.WriteHeader(204)

        return
}

func main() {
        s = sse.NewServer(nil) // Create the sse server.
        defer s.Shutdown()

        router := mux.NewRouter()
        router.HandleFunc("/api/var={var:[-.,0-9]+}", handlerVar)

        srv := &http.Server{
                Handler: router,
                Addr:    "0.0.0.0:" + pb.HTTPPort,
        }

        log.Println("Listening...")
        func() {
                log.Fatal(srv.ListenAndServe()) // start a http server
        }()
}