Skip to content

Instantly share code, notes, and snippets.

@alexedwards
Created May 10, 2025 09:41
Show Gist options
  • Save alexedwards/311aac24c3c2cdb71daf5307ac772f4f to your computer and use it in GitHub Desktop.
Save alexedwards/311aac24c3c2cdb71daf5307ac772f4f to your computer and use it in GitHub Desktop.
httprouter example
func main() {
router := httprouter.New()
router.HandlerFunc("GET", "/", indexGet)
router.HandlerFunc("POST", "/", indexPost)
err := http.ListenAndServe(":3000", router)
log.Fatal(err)
}
func indexGet(w http.ResponseWriter, r *http.Request) {
// Handle the GET request...
}
func indexPost(w http.ResponseWriter, r *http.Request) {
// Handle the POST request...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment