Context
I am trying to build a Go Serverless function with vercel, but my route needs a path parameter.
The Problem
How can I map path parameters in golang with vercel?
Attempts
- Given the following folder structure
- api
- user if i use code like
func GetUser(w http.ResponseWriter, r *http.Request) { usr := strings.TrimPrefix(r.URL.Path, "api/user/") if cal == "" { http.Error(w, "Invalid user", http.StatusBadRequest) return } _, err := w.Write([]byte(cal)) if err != nil { slog.Error("Error answering", err) }}But I when I make a request to /api/user/1 it returns a 404 (not found)
- Same but with [id] directory
- Same but with [id].go file