Skip to content

Commit d396f64

Browse files
committed
refactor(serverMux): simplify root handler creation
1 parent 9d78e31 commit d396f64

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/serveMux/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ func NewServeMux(
3939
errorHandler.LogError(err)
4040

4141
aliases := p.Aliases
42-
handlers := map[string]http.Handler{}
43-
4442
if _, hasRootAlias := aliases["/"]; !hasRootAlias {
45-
handlers["/"] = serverHandler.NewHandler(p.Root, "/", p, users, tplObj, logger, errorHandler)
43+
aliases["/"] = p.Root
4644
}
4745

48-
for urlPath, fsPath := range p.Aliases {
46+
handlers := map[string]http.Handler{}
47+
for urlPath, fsPath := range aliases {
4948
handlers[urlPath] = serverHandler.NewHandler(fsPath, urlPath, p, users, tplObj, logger, errorHandler)
5049
}
5150

0 commit comments

Comments
 (0)