This crate provides wasmCloud actors with an interface to the HTTP client capability provider. Actors using this
interface must have the claim wasmcloud:httpclient
in order to have permission to make outbound HTTP requests,
and they must have an active, configured binding to an HTTP Client capability provider.
wasmCloud actors without this permission and capability binding will be unable to make outbound HTTP requests.
```rust use wapcguest::HandlerResult; extern crate wasmcloudactorhttpserver as httpserver; extern crate wasmcloudactorhttpclient as httpclient; extern crate wasmcloudactor_core as actor;
const API_URL: &str = "https://wasmcloudapi.cloud.io/proxy";
pub fn init() { httpserver::Handlers::registerhandlerequest(get_proxy); }
/// This function proxys an inbound HTTP request to an external server
fn getproxy(msg: httpserver::Request) -> HandlerResultrequest
with httpclient::default().request
let res = request(msg.method, APIURL.tostring(), msg.header, vec![])?;
// Form server response
Ok(httpserver::Response {
statuscode: res.statuscode,
status: res.status,
header: res.header,
body: res.body,
})
} else {
Ok(httpserver::Response::internalservererror("Only GET requests can be proxied with this actor"))
}
}
```