Skip to content

Commit 4169f3c

Browse files
committed
Use a mux
1 parent 175b36b commit 4169f3c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cli.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro
4040
signal.Notify(sigintCh, os.Interrupt)
4141
defer signal.Stop(sigintCh)
4242

43-
doneCh := make(chan loginResp)
43+
doneCh := make(chan loginResp, 2)
4444

4545
mount, ok := m["mount"]
4646
if !ok {
@@ -80,7 +80,10 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro
8080
}
8181

8282
// Set up callback handler
83-
http.HandleFunc("/oidc/callback", callbackHandler(c, mount, clientNonce, doneCh))
83+
mux := http.NewServeMux()
84+
mux.HandleFunc("/oidc/callback", callbackHandler(c, mount, clientNonce, doneCh))
85+
srv := &http.Server{Handler: mux}
86+
srv.SetKeepAlivesEnabled(false)
8487

8588
listener, err := net.Listen("tcp", listenAddress+":"+port)
8689
if err != nil {
@@ -96,7 +99,7 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro
9699

97100
// Start local server
98101
go func() {
99-
err := http.Serve(listener, nil)
102+
err := srv.Serve(listener)
100103
if err != nil && err != http.ErrServerClosed {
101104
doneCh <- loginResp{nil, err}
102105
}

0 commit comments

Comments
 (0)