Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation of client request before use #153

Open
jonathanstowe opened this issue Sep 8, 2021 · 3 comments
Open

Transformation of client request before use #153

jonathanstowe opened this issue Sep 8, 2021 · 3 comments

Comments

@jonathanstowe
Copy link
Contributor

In order to make, for example, a Signed AWS request it would be handy if the Cro::HTTP::Client could have a mechanism that a Request -> Request transform ( or transforms) can be applied after the Request has been fully assembled and before the actual http request is made, such that new headers can be computed and added based on the headers and body of the request.

On the face of it it looks like it could be inserted in .request immediately before the $pipeline.send-request is called as that will be the last place the headers could be changed.

@jonathanstowe
Copy link
Contributor Author

Ah no, looking more deeply in the code it would seem the best place to add this would be in build-pipeline after the body serializers and before the request serializer is pushed. I'll have a poke.

@jnthn
Copy link
Member

jnthn commented Sep 10, 2021

An idea I had a long time back - but we never yet implemented - was to have middleware supported on the HTTP client, with an API like that on the server side. That would include being able to circumvent the entire request on the network and provide a response directly, so we could use it to implement all manner of things (local caching, circuit breaker, avoiding requests that would be beyond a rate limit, etc.) Then an API at construction time with before/after, again matching the HTTP server approach. I think the Cro::HTTP::Middleware interface should fit with client side as well as server side - at least, that was my hope.

@jonathanstowe
Copy link
Contributor Author

Yeah on the face of it that wouldn't require too much new code either as most of the parts from Server seem re-usable at first glance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants