Documentation
¶
Overview ¶
Package codec provides encoding and decoding functionality for different data formats.
Package codec provides encoding and decoding functionality for different data formats.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONCodec ¶
JSONCodec is a codec that uses JSON for marshaling and unmarshaling. It implements the Codec interface for encoding responses and decoding requests.
func NewJSONCodec ¶
NewJSONCodec creates a new JSONCodec instance for the specified types. T represents the request type and U represents the response type.
type ProtoCodec ¶
Force T to be a pointer to a type implementing proto.Message.
func NewProtoCodec ¶
func NewProtoCodec[T proto.Message, U proto.Message]() *ProtoCodec[T, U]
NewProtoCodec creates a new ProtoCodec instance.
func (*ProtoCodec[T, U]) Decode ¶
func (c *ProtoCodec[T, U]) Decode(r *http.Request) (T, error)
Decode reads the request body and unmarshals into T (which is a pointer).
func (*ProtoCodec[T, U]) Encode ¶
func (c *ProtoCodec[T, U]) Encode(w http.ResponseWriter, resp U) error
Encode marshals U (also a pointer type) and writes to response.