Last active
February 21, 2018 14:06
-
-
Save eyeezzi/61cce1bb507006b961761eba6ab3304b to your computer and use it in GitHub Desktop.
Alternative way to read JSON body using ioutil.ReadAll()
This file contains hidden or 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
func CreateNote(w http.ResponseWriter, r *http.Request) { | |
var m map[string]interface{} | |
body, err := ioutil.ReadAll(r.Body) | |
if err = json.Unmarshal(body, &m); err != nil { | |
http.Error(w, err.Error(), http.StatusInternalServerError) | |
return | |
} | |
fmt.Fprintln(w, "done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment