Skip to content

Commit 61bc75d

Browse files
committed
fix(vhostHandler): get single handler when handlers has 1 item
1 parent 8f76497 commit 61bc75d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/vhostHandler/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ func NewHandler(
6565
}
6666

6767
var handler http.Handler
68-
if len(handlers) == 0 {
68+
if len(handlers) == 1 {
6969
handler = handlers["/"]
70-
} else {
70+
}
71+
if handler == nil {
7172
serveMux := http.NewServeMux()
72-
for urlPath, handler := range handlers {
73-
serveMux.Handle(urlPath, handler)
73+
for urlPath, urlHandler := range handlers {
74+
serveMux.Handle(urlPath, urlHandler)
7475
if len(urlPath) > 1 {
75-
serveMux.Handle(urlPath+"/", handler)
76+
serveMux.Handle(urlPath+"/", urlHandler)
7677
}
7778
}
7879
handler = serveMux

0 commit comments

Comments
 (0)