If you are wondering about to handle a POST request? Then you might also have a second question about how to handle request payload right? I mean it's crucial every application to parse request body when it comes to POST request.

Parsing Payload of POST Request In Go

For POST request you will have ParseForm() method in your request object. Which essentially parse the raw data and put it on FormValue. You can access the entire payload by r.Form for access as key value pair using r.FormValue method

r.ParseForm(); // parse raw request
r.FormValue("email") // get email value from the payload

Running this example

go run main.go

Then send a post request to localhost:8080 with body name and email using Content-Type: application/x-www-form-urlencoded

Output for a post request

Post request found with name=myName, [email protected]