Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCodeMarshalResponseBodyFailed *string
)
Functions ¶
func PrecomputeMarshalByReflection ¶
func PrecomputeMarshalByReflection( v reflect.Value, marshalOptions *protojson.MarshalOptions, ) (map[string]interface{}, error)
PrecomputeMarshalByReflection marshals a struct to a map[string]interface{} using reflection, handling nested proto.Message fields appropriately
Parameters:
- v: The reflect.Value of the struct to marshal
- marshalOptions: The protojson.MarshalOptions to use (optional)
Returns:
- map[string]interface{}: The marshaled struct as a map
- error: The error if any
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is the implementation of the Encoder interface
func NewEncoder ¶
func NewEncoder( mode *goflagsmode.Flag, marshalOptions protojson.MarshalOptions, ) *Encoder
NewEncoder creates a new Encoder instance
Parameters:
- mode: the flag mode
- marshalOptions: options for marshaling protobuf messages to JSON
Returns:
- *Encoder: the new Encoder instance
func (Encoder) Encode ¶
func (e Encoder) Encode( w http.ResponseWriter, response gonethttpresponse.Response, ) error
Encode protobuf to JSON
Parameters:
- w: The HTTP response writer
- response: The response to encode, must have a data field that is a proto.Message
Returns:
- error: The error if any
Click to show internal directories.
Click to hide internal directories.