diff options
| author | Adnan Maolood <[email protected]> | 2021-02-24 10:27:28 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-24 10:27:28 -0500 |
| commit | 19bfca1cc30e305a97e149e721f8bf50ca7e045e (patch) | |
| tree | f7cdc4116ca3770ddd28a68c12fd5f1bb9ec5ef9 /examples | |
| parent | examples/server: Add logging middleware (diff) | |
| download | go-gemini-19bfca1cc30e305a97e149e721f8bf50ca7e045e.tar.xz go-gemini-19bfca1cc30e305a97e149e721f8bf50ca7e045e.zip | |
examples/server: Cancel context
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/server.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/server.go b/examples/server.go index 2f6ac88..29d5bf1 100644 --- a/examples/server.go +++ b/examples/server.go @@ -48,7 +48,8 @@ func main() { case <-c: // Shutdown the server log.Println("Shutting down...") - ctx, _ := context.WithTimeout(context.Background(), 30*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() err := server.Shutdown(ctx) if err != nil { log.Fatal(err) |