Skip to content

Instantly share code, notes, and snippets.

@michielmulders
Created December 16, 2020 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michielmulders/8c32a6978ec7829865608cd631e83c39 to your computer and use it in GitHub Desktop.
Save michielmulders/8c32a6978ec7829865608cd631e83c39 to your computer and use it in GitHub Desktop.
Post request Go web server
package main
import (
"log"
"net/http"
"io/ioutil"
)
func postRoute(rw http.ResponseWriter, req *http.Request) {
body, err := ioutil.ReadAll(req.Body)
if err != nil {
panic(err)
}
// further handle request
}
func main() {
http.HandleFunc("/postRoute", postRoute)
log.Fatal(http.ListenAndServe(":8080", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment