Created
December 16, 2020 10:56
-
-
Save michielmulders/8c32a6978ec7829865608cd631e83c39 to your computer and use it in GitHub Desktop.
Post request Go web server
This file contains 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
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