Skip to content

Commit ab6c123

Browse files
committed
perf(vhostHandler): use simple ServerHandler if no alias
1 parent f867efa commit ab6c123

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/vhostHandler/main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,18 @@ func NewHandler(
6262
}
6363

6464
var handler http.Handler
65-
serveMux := &http.ServeMux{}
66-
for urlPath, handler := range handlers {
67-
serveMux.Handle(urlPath, handler)
68-
if len(urlPath) > 1 {
69-
serveMux.Handle(urlPath+"/", handler)
65+
if len(handlers) == 0 {
66+
handler = handlers["/"]
67+
} else {
68+
serveMux := http.NewServeMux()
69+
for urlPath, handler := range handlers {
70+
serveMux.Handle(urlPath, handler)
71+
if len(urlPath) > 1 {
72+
serveMux.Handle(urlPath+"/", handler)
73+
}
7074
}
75+
handler = serveMux
7176
}
72-
handler = serveMux
7377

7478
vhostHandler := &VhostHandler{
7579
p: p,

0 commit comments

Comments
 (0)