Courses
Go Intermediate: Interfaces, Concurrency, and Services
Check Yourself
Five scenario questions on HTTP middleware wrapping, status capture, signal.NotifyContext, and server.Shutdown.
By Jay P
Updated
5 min
GoAPIs and IntegrationsTesting and DebuggingProgramming Patterns
Intermediate
Course content
Join this Course
Sign in to save your progress.
-
Interfaces and Standard Abstractions
-
Interfaces Are Satisfied Implicitly
-
Read and Stream With io.Reader and io.Writer
-
-
-
Context, Timeouts, and Cancellation
-
Use context.Context for Deadlines and Cancellation
-
Set Timeouts on HTTP Clients and Server Handlers
-
-
-
Goroutines, Channels, and Coordination
-
Run Concurrent Work Safely With sync.WaitGroup
-
Coordinate Pipelines and Timeouts With Channels and select
-
-
-
Structured Logging and Databases
-
Write Structured JSON Logs With log/slog
-
Query Relational Data Safely With database/sql
-
-
-
Middleware and Production-Ready Services
-
Wrap HTTP Handlers With Middleware
-
Build a Multi-Route Service With Graceful Shutdown
-
-
-
Generics, Transactions, Timers, and Test Doubles
-
Generics, Constraints, and slices/maps Packages
-
SQL Transactions and Connection Pool Limits
-
Timers, Tickers, and Avoiding time.After Leaks
-
Testing With Interface Fakes, t.TempDir, and testdata
-
-
1.
Why does a logging middleware wrap `http.ResponseWriter` in a custom `statusRecorder` struct?
2.
If a handler writes `w.Write([]byte("ok"))` without calling `w.WriteHeader(...)`, what status code should `statusRecorder` default to?
3.
An auth middleware sees an invalid token, writes `401 Unauthorized`, and forgets to `return`. What goes wrong?
4.
Why does `run()` give `srv.Shutdown(shutCtx)` a fresh `context.WithTimeout(context.Background(), 5*time.Second)` instead of reusing the signal `ctx`?
5.
When `srv.Shutdown` is called, `srv.ListenAndServe()` returns `http.ErrServerClosed`. Should `run()` treat that as a fatal crash?
About
Five scenario questions on HTTP middleware wrapping, status capture, signal.NotifyContext, and server.Shutdown.
- Duration
- 5 min
- Last update
- 11/27/2026
Was this helpful?
0
0
Comments
Sign in to commentNo comments yet.