Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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