MCPcopy Create free account
hub / github.com/dolanor/rip / decode

Function decode

handler.go:125–134  ·  view source on GitHub ↗

decode use the content type to decode the data from r into t.

(r io.Reader, contentType string, options *RouteOptions)

Source from the content-addressed store, hash-verified

123
124// decode use the content type to decode the data from r into t.
125func decode[T any](r io.Reader, contentType string, options *RouteOptions) (T, error) {
126 var t T
127 decoder, err := encoding.ContentTypeDecoder(r, contentType, options.codecs)
128 if err != nil {
129 return t, err
130 }
131
132 err = decoder.Decode(&t)
133 return t, err
134}
135
136// decodeIn use the content type to decode the data from r into t (which should be a pointer).
137func decodeIn(t any, r io.Reader, contentType string, options *RouteOptions) (any, error) {

Callers

nothing calls this directly

Calls 2

ContentTypeDecoderFunction · 0.92
DecodeMethod · 0.65

Tested by

no test coverage detected