_, err := db.ExecContext(ctx, "SELECT pg_sleep(10)") return err }... func exampleHandler(w http.ResponseWriter, r *http.Request) { // Pass the request context to slowQuery(), so it can be used as the // parent context.
err := slowQuery(r.Context()) if err!= nil { serverError(w, err) return } fmt.Fprintln(w, "OK") }...