-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Is your feature request related to a problem? Please describe.
When I write a worker, I can only rely on the data that comes from a local file (mounted folders), environments variables or hardcoded in code. This reduces the kind of projects I can develop.
Describe the solution you'd like
I would like to call an external HTTP API from inside a worker. Every language has its own way to do it, so I want to use those common patterns. For example, the fetch method is the most common API for calling an HTTP endpoint in JavaScript.
To follow the capability-based approach, I want to configure the HTTP endpoints a worker can call. I want to avoid a worker calling random HTTP endpoints. For this, I would add a new section in the TOML file called "features". This object includes one configuration per feature like:
[features]
[features.fetch]
allowed_domains = ["https://example.com"]
force_ssl = trueHost implementation
- Define the bindings with WIT (feat: add the HTTP bindings to perform HTTP requests from workers #168)
- Implement the bindings on the host side (feat: add the HTTP bindings to perform HTTP requests from workers #168)
- Configure the workers so developers configure the allowed requests. By default, all requests will be rejected. (feat: allow configuring the http_requests via TOML #174)
Language implementation
I will start with JavaScript, but I will extend the support to other languages soon:
- JavaScript (feat: add the fetch and more APIs to the JavaScript kit #169)
- Rust (feat: add new fetch bindings to the rust kit #171)
- Go (feat: add new Go bindings to perform HTTP requests #173)