Skip to content

Commit

Permalink
Extend file and spa handler registration with possible methods #59
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Ludwig committed Nov 9, 2020
1 parent 05d7c2e commit c80378f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ var allowedMethods = []string{
http.MethodOptions,
}

var fileMethods = []string{
http.MethodGet,
http.MethodHead,
http.MethodOptions,
}

func NewMux(options *runtime.MuxOptions) *Mux {
opts := options
if opts == nil {
Expand All @@ -64,12 +70,13 @@ func NewMux(options *runtime.MuxOptions) *Mux {
mux.mustAddRoute(mux.endpointRoot, allowedMethods, path, h)
}

fileMethods := []string{http.MethodGet, http.MethodOptions, http.MethodHead}
for path, h := range opts.FileRoutes {
mux.mustAddRoute(mux.fileRoot, []string{http.MethodGet}, utils.JoinPath(path, "/**"), h)
mux.mustAddRoute(mux.fileRoot, fileMethods, utils.JoinPath(path, "/**"), h)
}

for path, h := range opts.SPARoutes {
mux.mustAddRoute(mux.spaRoot, []string{http.MethodGet}, path, h)
mux.mustAddRoute(mux.spaRoot, fileMethods, path, h)
}

return mux
Expand Down

0 comments on commit c80378f

Please sign in to comment.