tusd
tusd copied to clipboard
Retain request context values while detaching to avoid cancellation.
Copypasta of @Acconut solution to #315
Thanks for the PR. Can you add a test to ensure that the context values from the HTTP request are actually accessible?
This only makes the original ctx
available for DataStore
s, right?
So there's still no way to access the context from HookEvent
s 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?
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.
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.