Skip to content

Canceling request #1815

Answered by aldas
Thodoras asked this question in Q&A
Mar 18, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can access request context with c.Request().Context() assuming handler had signature func(c echo.Context) error and pass it to your services/methods/clients so they could end when client closes the connection.

See
https://github.com/golang/go/blob/732ea4c2dcc1bcbcff65c31047ebb54364e7865d/src/net/http/request.go#L336

// For incoming server requests, the context is canceled when the
// client's connection closes, the request is canceled (with HTTP/2),
// or when the ServeHTTP method returns.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Thodoras
Comment options

Answer selected by aldas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants