Skip to content

Commit e02fa93

Browse files
committed
Use a mux
1 parent 175b36b commit e02fa93

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cli.go

Lines changed: 7 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,11 @@ 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)
87+
defer srv.Close()
8488

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

97101
// Start local server
98102
go func() {
99-
err := http.Serve(listener, nil)
103+
err := srv.Serve(listener)
100104
if err != nil && err != http.ErrServerClosed {
101105
doneCh <- loginResp{nil, err}
102106
}

0 commit comments

Comments
 (0)