gobuch/microservices/formrequest/main.go

19 lines
340 B
Go
Raw Normal View History

2020-08-21 04:26:40 +00:00
package main
import "net/http"
func handleForm(rw http.ResponseWriter, rq *http.Request) {
err := rq.ParseForm()
if err != nil {
rw.WriteHeader(http.StatusNotAcceptable)
return
}
name := rq.Form.Get("name")
rw.Write([]byte("Hello " + name))
}
func main() {
http.HandleFunc("/", handleForm)
http.ListenAndServe(":8080", nil)
}