Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Update: Add JSONDecoder to config #1489

Merged
merged 2 commits into from
Aug 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ type Config struct {
// Default: json.Marshal
JSONEncoder utils.JSONMarshal `json:"-"`

// When set by an external client of Fiber it will use the provided implementation of a
// JSONUnmarshal
//
// Allowing for flexibility in using another json library for encoding
// Default: json.Unmarshal
JSONDecoder utils.JSONUnmarshal `json:"-"`

// Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only)
// WARNING: When prefork is set to true, only "tcp4" and "tcp6" can be chose.
//
Expand Down Expand Up @@ -459,6 +466,9 @@ func New(config ...Config) *App {
if app.config.JSONEncoder == nil {
app.config.JSONEncoder = json.Marshal
}
if app.config.JSONDecoder == nil {
app.config.JSONDecoder = json.Unmarshal
}
if app.config.Network == "" {
app.config.Network = NetworkTCP4
}
Expand Down