apollographql / router

A configurable, high-performance routing runtime for Apollo Federation 🚀
https://www.apollographql.com/docs/router/
Other
808 stars 272 forks source link

add host getter/setters to http_compat and expose in rhai #1264

Open garypen opened 2 years ago

garypen commented 2 years ago

1258 prompted some interesting debate about the correct way for router plugins (and the router itself) to get/set "host" details. Largely, this is because of the different ways in which this information is conveyed over different revisions (and implementations) of the HTTP protocol.

The router engineering team resolved to merge the PR that resolves #1258 as is and then file this followup issue to note that we'd really like to have convenience getter/setter for host manipulation that can be used by plugins and exposed to rhai.

Here's what we'd like (roughly, in pseudo-rust)

\\\ Try to find host details by:
\\\  - Examining HOST header
\\\  - Examining request host attribute
\\\  - If not found return None
Request::get_host(&self) -> Option<&str>;

\\\ Try to update host details by:
\\\  - Updating HOST header (if present)
\\\  - Updating request host attribute
Request::set_host(&mut self, host: &str);
SimonSapin commented 2 years ago

Can this be added backward-compatibly after 1.0?

Do we want to have it for 1.0 anyway?

o0Ignition0o commented 2 years ago

It imo is even less important given the fact we d like to separate the http and the gql parts of the lifecycle even further.

garypen commented 2 years ago

This could be done post 1.0, so removing the 1.0 label. If you feel strongly that it should be 1.0, add it back with a comment.