You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Encoder is the function type needed for request encoderstypeEncoderfunc(req*http.Request, reqObjectinterface{}) error//Decoder is the function type needed for response decoderstypeDecoderfunc(ctx context.Context, w http.ResponseWriter, encodeError, endpointErrorerror, respObjectinterface{})
Encoder extracts information from incoming http request and convert to a request object. Decoder takes a response object to write it into http response.
Essentially, Encoders does unmarshalling and deserializing action, while Decoders does marshalling and serializing. The name and what exactly it does seems opposite.
Orion defines func prototypes
Encoder
andDecoder
for handling http request/response as https://github.com/carousell/Orion/blob/master/orion/handlers/types.go#L40-L44:Encoder
extracts information from incoming http request and convert to a request object.Decoder
takes a response object to write it into http response.Essentially,
Encoders
does unmarshalling and deserializing action, whileDecoders
does marshalling and serializing. The name and what exactly it does seems opposite.Even in Orion's code, we can find this confusion: https://github.com/carousell/Orion/blob/master/orion/handlers/http/http.go#L176-L188. In the beginning of the section, the comment says "decoder func", but it calls encoders later.
Should them switch names?
The text was updated successfully, but these errors were encountered: