The HTTP POST form is a very common way of passing the information to the server, in a structured way. This recipe shows how to parse and access these on the server side.
Resolving form variables
How to do it...
- Open the console and create the folder chapter09/recipe12.
- Navigate to the directory.
- Create the file form.go with the following content:
package main
import (
"fmt"
"net/http"
)
type StringServer string
func (s StringServer) ServeHTTP(rw http.ResponseWriter,
req *http.Request) {
fmt.Printf("Prior ParseForm: %v\n", req.Form)
req.ParseForm()
fmt.Printf("Post ParseForm: %v...