Documentation ¶
Index ¶
- Variables
- func Parse(req *http.Request, obj any) error
- func RawWrite(w io.Writer, obj any) error
- func Read(resp *http.Response, obj any) error
- func Stream[T any](reader io.Reader, output chan<- T, key string, closeChan bool) error
- func Write(ctx context.Context, w http.ResponseWriter, status int, obj any)
- func WriteArray(ctx context.Context, w http.ResponseWriter, status int, array any)
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCannotMarshal = errors.New("cannot marshal json")
)
Functions ¶
func Stream ¶ added in v4.9.0
Stream decodes JSON from a `reader` and send unmarshalled `T` to the given `output` chan `closeChan` make Stream to close the `output` channel once read. There is no guarantee that the `reader` wil be fully read. For HTTP Body you might want to drain it.
`key` supports three kinds of values: - "" => the reader contains a stream of objects like `{"id":12}{"id":34}{"id":56}`, e.g. processing a websocket - "." => the reader contains an array of objects like `[{"id":12},{"id":34},{"id":56}]` - <key name>" => the reader contains an array of objects at the given root key `{"items":[{"id":12},{"id":34},{"id":56}]}`.
func WriteArray ¶ added in v4.5.0
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.