ContentTypeDecoder decodes the encoded data from r based on the Content-Type header value and the codecs that are available. If no codec is found, it returns a [ErrNoEncoderAvailable].
(r io.Reader, contentTypeHeader string, codecs Codecs)
| 61 | // and the codecs that are available. |
| 62 | // If no codec is found, it returns a [ErrNoEncoderAvailable]. |
| 63 | func ContentTypeDecoder(r io.Reader, contentTypeHeader string, codecs Codecs) (Decoder, error) { |
| 64 | decoder, ok := codecs.Codecs[contentTypeHeader] |
| 65 | if !ok { |
| 66 | return nil, ErrNoEncoderAvailable |
| 67 | } |
| 68 | |
| 69 | return decoder.NewDecoder(r), nil |
| 70 | } |
| 71 | |
| 72 | // Encoder writes encoded value to an output stream. |
| 73 | type Encoder interface { |
no outgoing calls
no test coverage detected