zed_extension_api: Add fetch
(#13716)
This PR adds a new `fetch` function to the `zed_extension_api` to allow fetching a URL through the Wasm host. Currently we only support GET requests and return the response body as a string. Release Notes: - N/A
This commit is contained in:
parent
e7214a429d
commit
3419f5fc42
4 changed files with 56 additions and 1 deletions
|
@ -2,6 +2,7 @@ package zed:extension;
|
|||
|
||||
world extension {
|
||||
import github;
|
||||
import http-client;
|
||||
import platform;
|
||||
import nodejs;
|
||||
|
||||
|
|
16
crates/extension_api/wit/since_v0.0.7/http-client.wit
Normal file
16
crates/extension_api/wit/since_v0.0.7/http-client.wit
Normal file
|
@ -0,0 +1,16 @@
|
|||
interface http-client {
|
||||
/// An HTTP request.
|
||||
record http-request {
|
||||
/// The URL to which the request should be made.
|
||||
url: string,
|
||||
}
|
||||
|
||||
/// An HTTP response.
|
||||
record http-response {
|
||||
/// The response body.
|
||||
body: string,
|
||||
}
|
||||
|
||||
/// Performs an HTTP request and returns the response.
|
||||
fetch: func(req: http-request) -> result<http-response, string>;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue