Signing requests with path parameters
lfrestrepog opened this issue · comments
Hi, good day!
Some endpoints of an API I'm using require a signature of the request, as follows:
- Concatenate a nonce, the method, the url and the params, separated with
|
. Sononce|method|url|params
- Sign that string using hmac sha256 and my key.
All good, except when I use path parameters the url should have the actual parameters instead of the placeholders. As a workarround I just build my path string with fmt.Sprintf
instead of using the path parameters feature. It would be better if there was any way to access the final path before the request is sent to the server, perhaps a callback like OnBeforeRequest
. I actually tried it but, as is well described in the documentation, it is called before resty's middlewares, so the path parameters are not yet replaced.
What's the recommended way to sign requests when one needs the path to be signed too?
@lfrestrepog You could use SetPreRequestHook
to achieve it.