Read & Write JSON
Read JSON
func (ro *Router) HandleRocketLaunch(w http.ResponseWriter, r *http.Request) {
var body struct {
RocketID string `json:"rocket_id"`
}
if ok := ro.rw.ReadJSON(w, r, &body); !ok {
return
}
// Handle request with body..
}Validate Request Body
var body struct {
RocketID string `json:"rocket_id" valid:"required`
}Write JSON
Last updated