expect-digital / go-request

MIT License
1 stars 0 forks source link

Decode embedded structs #8

Closed janishorsts closed 3 years ago

janishorsts commented 3 years ago

Use all fields from embedded structs when decoding the HTTP request.

type Sort struct {
  Name string
  Asc bool
}

func (s *Sort) UnmarshalText(text []byte) error {}

type Range struct {
  Start int `query:"rangeStart"`
  End   int `query:"rangeEnd"`
}

var req struct {
  Sort
  Range
}

// ?sort=name&rangeStart=0&rangeEnd=
Decode(r, &req)