Created
May 10, 2025 09:41
-
-
Save alexedwards/311aac24c3c2cdb71daf5307ac772f4f to your computer and use it in GitHub Desktop.
httprouter example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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