Skip to content

Commit

Permalink
Add RegisterBodyEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
kkroo committed Nov 7, 2022
1 parent 9ea22ae commit e354095
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions openapi3filter/req_resp_encoder.go
Expand Up @@ -21,3 +21,13 @@ type bodyEncoder func(body interface{}) ([]byte, error)
var bodyEncoders = map[string]bodyEncoder{
"application/json": json.Marshal,
}

func RegisterBodyEncoder(contentType string, encoder bodyEncoder) {
if contentType == "" {
panic("contentType is empty")
}
if encoder == nil {
panic("decoder is not defined")
}
bodyEncoders[contentType] = encoder
}

0 comments on commit e354095

Please sign in to comment.