Skip to content

Commit

Permalink
Fix nil muxOptions #59
Browse files Browse the repository at this point in the history
e.g. tests
  • Loading branch information
Marcel Ludwig committed Nov 9, 2020
1 parent c1b066e commit f1cbd2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestHTTPServer_ServeHTTP_UUID_Option(t *testing.T) {
log, hook := logrustest.NewNullLogger()
conf := *runtime.DefaultHTTP
conf.RequestIDFormat = testcase.formatOption
srv := server.New(context.Background(), log, &conf, "0", nil)
srv := server.New(context.Background(), log, &conf, "test", "0", nil)
srv.Listen()
defer srv.Close()

Expand Down
10 changes: 9 additions & 1 deletion server/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ var allowedMethods = []string{
http.MethodOptions,
}

func NewMux(opts *runtime.MuxOptions) *Mux {
func NewMux(options *runtime.MuxOptions) *Mux {
opts := options
if opts == nil {
opts = &runtime.MuxOptions{
APIErrTpl: errors.DefaultJSON,
FileErrTpl: errors.DefaultHTML,
}
}

mux := &Mux{
apiPath: opts.APIPath,
apiErrHandler: opts.APIErrTpl,
Expand Down

0 comments on commit f1cbd2e

Please sign in to comment.