Skip to content

Instantly share code, notes, and snippets.

@cheikhsimsol
Last active February 3, 2024 06:39
Show Gist options
  • Save cheikhsimsol/eb0c31e27cd29969cbee808db9dbe7e3 to your computer and use it in GitHub Desktop.
Save cheikhsimsol/eb0c31e27cd29969cbee808db9dbe7e3 to your computer and use it in GitHub Desktop.
Classic routing
message := "Hello World"
// Map a route to handle requests to the root path ("/")
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
// get code
fmt.Fprint(w, message)
case http.MethodPost:
// patch Code
message = "Hello Zod"
fmt.Fprint(w, "Resource Updated")
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment