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
We have a use-case where, while building a request through a RequestBuilder, we need to access the currently generated url of the request to generate a signature.
e.g.
fnprepare_request() -> Result<RequestBuilder,/* ... */>{Ok(client
.get(url).query(&[("lang", lang)]),// or any other serializable structure, possibly a generic type parameter...).header("signature",hmac(/*need full URL here*/, secret)))}
For that use-case, it would be useful to be able to access the current Request from the RequestBuilder: we could then write this function in the following way:
fnprepare_request() -> Result<RequestBuilder,/* ... */>{let request_builder = client
.get(url).query(&[("lang", lang)]),// or any other serializable structure, possibly a generic type parameter...);Ok(request_builder.header("signature",hmac(request_builder.request()?.url(), secret)))}
The text was updated successfully, but these errors were encountered:
@Ten0 what is the reason behind returning RequestBuilder instead of Request? You can always add the signature later by mutating your request object via Request::headers_mut().
It's part of a request building framework where other operands may be chained behind, so it is required that the return of each operand is a RequestBuilder.
We have a use-case where, while building a request through a
RequestBuilder
, we need to access the currently generated url of the request to generate a signature.e.g.
For that use-case, it would be useful to be able to access the current
Request
from theRequestBuilder
: we could then write this function in the following way:The text was updated successfully, but these errors were encountered: