qri-io / starlib

qri's standard library for starlark
MIT License
116 stars 29 forks source link

feat(http): allow RequestGuard to modify request #143

Closed rohansingh closed 2 years ago

rohansingh commented 2 years ago

Update the signature of RequestGuard.Allowed to accept a pointer to the current Starlark thread, and to return an *http.Request.

This allows a RequestGuard implementation to modify the HTTP request before it is executed, and to do so on a per-thread basis if desired.

rohansingh commented 2 years ago

This is a breaking change on the RequestGuard interface, but it's also a small change that adds a lot of functionality. Use cases include:

dustmop commented 2 years ago

Sounds fine! Simple enough of a change, and it doesn't break our own usage in a major way. LGTM

rohansingh commented 2 years ago

Thanks for the quick merge! :)