-
Suppose that I have an endpoint, which gets data from complex queries, makes calls to other services to get additional data and merges all of them using cumbersome algorithms to create the response. My question is this: If a consumer of the above endpoint decides to cancel her request, is there a "cancel context" functionality of echo that I should implement/use to cancel all remaining processes regarding that request in order to save resources? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can access request context with
|
Beta Was this translation helpful? Give feedback.
You can access request context with
c.Request().Context()
assuming handler had signaturefunc(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