Skip to content

Implements http.send builtin #218

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MatMaul
Copy link

@MatMaul MatMaul commented May 6, 2025

Spec

Implemented:

  • url
  • method
  • body
  • raw_body
  • headers
  • enable_redirect
  • force_json_decode
  • force_yaml_decode
  • timeout
  • raise_error
  • max_retry_attempts

The rest of the parameters are about TLS and cache behavior control and are not implemented.

serde_yaml has been replaced by serde_yml since the former is unmaintained.

@MatMaul MatMaul changed the title Implements http.send builtin Implements http.send builtin May 6, 2025
@MatMaul MatMaul force-pushed the implements-http-send branch from 3ba0c9c to b8ba15b Compare May 6, 2025 12:25
@MatMaul MatMaul force-pushed the implements-http-send branch from b8ba15b to ed5b169 Compare May 6, 2025 12:32
@Lupus
Copy link

Lupus commented May 8, 2025

Would be awesome to be able to provide custom implementation for actual HTTP client when initializing the policy evaluator or probably runtime. As WASM OPA backend does not support custom built-ins unlike Golang interpreted version, custom HTTP client could be used to call back into the host application from the policy to perform some actions which are not convenient to express via OPA (do some DB request, or actually perform HTTP request or a set of HTTP requests which are a single logical operation from policy perspective).

@MatMaul
Copy link
Author

MatMaul commented May 14, 2025

@Lupus I think what you want to do is already possible with this PR: you can provide your own implementation of send_http by customizing the context before instantiating the engine.

It can be the use of another HTTP lib than reqwest, or something that would intercept specific calls and forward to the default reqwest impl if not intercepted.

Lupus added a commit to Lupus/rust-opa-wasm that referenced this pull request May 21, 2025
This is largely a derived work on top of
[matrix-org/rust-opa-wasm!218](matrix-org#218)
which was authored by [@MatMaul](https://github.com/MatMaul).
Lupus added a commit to Lupus/rust-opa-wasm that referenced this pull request May 21, 2025
This is largely a derived work on top of
[matrix-org/rust-opa-wasm!218](matrix-org#218)
which was authored by [@MatMaul](https://github.com/MatMaul).

Signed-off-by: Konstantin A. Olkhovskiy <[email protected]>
Lupus added a commit to Lupus/rust-opa-wasm that referenced this pull request May 21, 2025
This is largely a derived work on top of
[matrix-org/rust-opa-wasm!218](matrix-org#218)
which was authored by [@MatMaul](https://github.com/MatMaul).

Signed-off-by: Konstantin A. Olkhovskiy <[email protected]>
Lupus added a commit to Lupus/rust-opa-wasm that referenced this pull request May 21, 2025
This is largely a derived work on top of
[matrix-org/rust-opa-wasm!218](matrix-org#218)
which was authored by [@MatMaul](https://github.com/MatMaul).

Signed-off-by: Konstantin A. Olkhovskiy <[email protected]>
@Lupus
Copy link

Lupus commented May 21, 2025

@MatMaul could you please provide a sign-off according to this repository's contribution guidelines?

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

Successfully merging this pull request may close these issues.

2 participants