tusd icon indicating copy to clipboard operation
tusd copied to clipboard

Retain request context values while detaching to avoid cancellation.

Open innovate-invent opened this issue 4 years ago • 3 comments

Copypasta of @Acconut solution to #315

innovate-invent avatar Jan 03 '20 02:01 innovate-invent

Thanks for the PR. Can you add a test to ensure that the context values from the HTTP request are actually accessible?

Acconut avatar Jan 20 '20 07:01 Acconut

This only makes the original ctx available for DataStores, right?

So there's still no way to access the context from HookEvents right? Is that by design or just missing? If by design, what's the reason for that?

edit: So right now the only way to pass additional data to the HookEvent would probably be by messing with the headers?

dschmidt avatar Apr 08 '20 16:04 dschmidt

This only makes the original ctx available for DataStores, right?

Yes, correct.

So there's still no way to access the context from HookEvents right? Is that by design or just missing? If by design, what's the reason for that?

Yes, it's not really a design decision but grew naturally that way. The hook system was built before contexts existed in Go, so they were not included in the design of the hooks.

So right now the only way to pass additional data to the HookEvent would probably be by messing with the headers?

You can do that. But it depends on what additional data you want to pass on and where it comes from.

Acconut avatar May 01 '20 14: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