O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Contact form Rest API endpoint

Inside the igweb.go source file, we have registered the /restapi/contact-form endpoint and it's associated handler function, ContactFormEndpoint:

r.Handle("/restapi/contact-form", endpoints.ContactFormEndpoint(env)).Methods("POST")

The ContactFormEndpoint function is responsible for servicing the /restapi/contact-form endpoint:

func ContactFormEndpoint(env *common.Env) http.Handler {  return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {    var fields map[string]string    reqBody, err := ioutil.ReadAll(r.Body)    if err != nil {      log.Print("Encountered error when attempting to read the request body: ", err)    }    err = json.Unmarshal(reqBody, &fields)    if err != nil { log.Print("Encountered error when attempting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required