aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-24 10:27:28 -0500
committerAdnan Maolood <[email protected]>2021-02-24 10:27:28 -0500
commit19bfca1cc30e305a97e149e721f8bf50ca7e045e (patch)
treef7cdc4116ca3770ddd28a68c12fd5f1bb9ec5ef9 /examples
parentexamples/server: Add logging middleware (diff)
downloadgo-gemini-19bfca1cc30e305a97e149e721f8bf50ca7e045e.tar.xz
go-gemini-19bfca1cc30e305a97e149e721f8bf50ca7e045e.zip
examples/server: Cancel context
Diffstat (limited to 'examples')
-rw-r--r--examples/server.go3
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)