tusd icon indicating copy to clipboard operation
tusd copied to clipboard

Passing also context.Context to PreUpload and PreFinish callbacks

Open stefan-scheidewig opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. We are using v2 as a library integrated into a go-chi application. Within that application every handler is mounted after an authentication handler, which authenticates the request and enriches the context with necessary information. We are using the PreFinishResponseCallback for processing the uploaded file when the last PATCH request is made. Within that logic we have to access information from that context to decide how to further process the file but only the HookEvent information are passed into the callback method.

Describe the solution you'd like We would ask you if it would be possible to also pass the original context.Context into these callbacks.

stefan-scheidewig avatar Apr 28 '22 03:04 stefan-scheidewig

Adding to that: having the hooks be called with the context.Context of the incoming request (or a child of it) makes sense, since the hooks might make outgoing calls themselves that should be cancelled if the incoming request is cancelled and/or that should have access to enriched information like the opentracing span.

aksdb avatar Apr 28 '22 07:04 aksdb

Good idea, it makes sense to expose contexts to these callbacks. Feel free to open a PR to add this to the v2 branch.

Acconut avatar May 03 '22 08:05 Acconut

Thanks you for your contribution! In tusd v2, the request context will be accessible in the hooks and stores. Please see #986 for more details and #672 for the development of v2.

Acconut avatar Aug 23 '23 11:08 Acconut