diff options
| author | Adnan Maolood <[email protected]> | 2021-02-22 21:16:13 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-22 21:16:13 -0500 |
| commit | 3b8b5d6557e367bebf60a56f285b2b55b5648d92 (patch) | |
| tree | b20677fcfde09f4b46f393358943b3e2cd8847bb /examples | |
| parent | examples/server: Shutdown on interrupt signal (diff) | |
| download | go-gemini-3b8b5d6557e367bebf60a56f285b2b55b5648d92.tar.xz go-gemini-3b8b5d6557e367bebf60a56f285b2b55b5648d92.zip | |
examples/stream: Remove /shutdown handler
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stream.go | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/examples/stream.go b/examples/stream.go index f4cbf09..325555d 100644 --- a/examples/stream.go +++ b/examples/stream.go @@ -8,7 +8,6 @@ import ( "context" "fmt" "log" - "sync" "time" "git.sr.ht/~adnano/go-gemini" @@ -32,21 +31,9 @@ func main() { GetCertificate: certificates.GetCertificate, } - var shutdownOnce sync.Once - var wg sync.WaitGroup - wg.Add(1) - defer wg.Wait() - mux.HandleFunc("/shutdown", func(ctx context.Context, w gemini.ResponseWriter, r *gemini.Request) { - fmt.Fprintln(w, "Shutting down...") - w.Flush() - go shutdownOnce.Do(func() { - server.Shutdown(context.Background()) - wg.Done() - }) - }) - - if err := server.ListenAndServe(context.Background()); err != nil { - log.Println(err) + ctx := context.Background() + if err := server.ListenAndServe(ctx); err != nil { + log.Fatal(err) } } |