You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**What**
- Update to the latest of-watchdog 0.7.7, ensureing the request context
is propagated correctly
- Add examples of how to use the context to abort requests early
Signed-off-by: Lucas Roesler <[email protected]>
The `Request` object provides access to the request context. This allows you to check if the request has been cancelled by using the context's done channel `req.Context().Done()` or the context's error `req.Context().Err()`
This context can also be passed to other methods so that they can respond to the cancellation as well, for example [`db.ExecContext(req.Context())`](https://golang.org/pkg/database/sql/#DB.ExecContext)
181
+
182
+
147
183
## 2.0 golang-middleware
148
184
149
185
This template uses the [http.HandlerFunc](https://golang.org/pkg/net/http/#HandlerFunc) as entry point.
@@ -254,6 +290,7 @@ func init() {
254
290
255
291
funcHandle(whttp.ResponseWriter, r *http.Request) {
256
292
varquerystring
293
+
ctx:= r.Context()
257
294
258
295
if r.Body != nil {
259
296
defer r.Body.Close()
@@ -272,15 +309,19 @@ func Handle(w http.ResponseWriter, r *http.Request) {
0 commit comments