package meta import ( "net/http" "strconv" ) type Meta struct { Pretty bool `json:"pretty"` Envelope bool `json:"envelope"` } func NewFromRequest(r *http.Request) *Meta { meta := Meta{ Pretty: false, Envelope: false, } pretty, ok := r.URL.Query()["pretty"] if ok && len(pretty) > 0 { prettyBool, err := strconv.ParseBool(pretty[0]) if err == nil { meta.Pretty = prettyBool } } envelope, ok := r.URL.Query()["envelope"] if ok && len(envelope) > 0 { envelopeBool, err := strconv.ParseBool(envelope[0]) if err == nil { meta.Envelope = envelopeBool } } return &meta }