You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
Platforms like Cloudflare Workers or Shopify Oxygen may need to add additional information to requests/responses. Cloudflare Workers has a proprietary .cf property which includes fields like geolocation data etc. Shopify's Oxygen runtime has similar needs but uses custom HTTP headers to pass the data.
Since the standard doesn't offer any way to pass extra meta information along with Request/Response instances, it would be great to explore these and similar scenarios to see how the extra meta data may be added. There likely were no use cases for this in the browser world, but on the server side, the situation is different.
Using extra HTTP custom headers might be the most obvious approach, but it has a clear downside that headers have tight size limits, aren't very suitable for holding complex data, and can't contain anything that isn't directly serialisable into a string.
A custom property like .meta or .metadata (which should hold a JavaScript object, leaving its fields up to the vendor implementation) would be more flexible but needs to be standardised.
The text was updated successfully, but these errors were encountered:
I do not think Request or Response should have a custom meta property... there are other ways to go around it... like emitting a event that may include both a cf and a request property { cf: { ... }, request: new Request( ... ) }
there is also the possibility to hook in other meta property and bind it to request without actually modifying the request...
you could use WeakMap to bind other meta data to it.
constwm=newWeakMap()constreq=newRequest( ... )constcf={country: 'sweden'}wm.set(req,cf)wm.get(req)// return custom meta associated to the request
Platforms like Cloudflare Workers or Shopify Oxygen may need to add additional information to requests/responses. Cloudflare Workers has a proprietary
.cf
property which includes fields like geolocation data etc. Shopify's Oxygen runtime has similar needs but uses custom HTTP headers to pass the data.Since the standard doesn't offer any way to pass extra meta information along with
Request
/Response
instances, it would be great to explore these and similar scenarios to see how the extra meta data may be added. There likely were no use cases for this in the browser world, but on the server side, the situation is different.Using extra HTTP custom headers might be the most obvious approach, but it has a clear downside that headers have tight size limits, aren't very suitable for holding complex data, and can't contain anything that isn't directly serialisable into a string.
A custom property like
.meta
or.metadata
(which should hold a JavaScript object, leaving its fields up to the vendor implementation) would be more flexible but needs to be standardised.The text was updated successfully, but these errors were encountered: