Last active
December 19, 2022 11:38
-
-
Save karl-gustav/b35007ac413f9aa0936a8e680e34b88e to your computer and use it in GitHub Desktop.
Decode directly from request in golang webserver
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
var subscription Subscription | |
err := json.NewDecoder(r.Body).Decode(&subscription) | |
if err != nil { | |
http.Error(w, err.Error(), http.StatusBadRequest) | |
return | |
} | |
defer r.Body.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment