Skip to content

Commit 26cefac

Browse files
committed
fix: panic in logged handler
1 parent 12788b3 commit 26cefac

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

daemon_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ func TestListClients(t *testing.T) {
1212
response := httptest.NewRecorder()
1313

1414
vhostMux := CreateVhostMux([]string{}, true)
15-
rootMux := NewLoggedHandler(vhostMux)
15+
lh := NewLoggedHandler(vhostMux)
1616

1717
// start daemon
18-
d := NewDaemon(vhostMux, rootMux, "127.0.0.1", 80, 443)
18+
d := NewDaemon(lh, "127.0.0.1", 80, 443)
1919

2020
d.listClients(response, request)
2121
if response.Code != http.StatusOK {

logged_handler.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ type LoggedHandler struct {
2121
}
2222

2323
// NewLoggedHandler wraps the given handler with a request/response logger
24-
func NewLoggedHandler(handler http.Handler) *LoggedHandler {
24+
func NewLoggedHandler(vm *VhostMux) *LoggedHandler {
2525
lh := &LoggedHandler{
2626
ServeMux: http.NewServeMux(),
2727
VhostLogListeners: make(map[string]chan string),
28+
vhostMux: vm,
2829
}
29-
lh.Handle("/", handler)
30+
lh.Handle("/", vm)
3031
return lh
3132
}
3233

0 commit comments

Comments
 (0)