Skip to content

Commit

Permalink
feat: allow passing a Vec<u8> as body when making requests from a worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelmmiguel committed Jul 5, 2023
1 parent 3473412 commit 6b6efab
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kits/rust/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ impl From<HttpResponse> for Response<Vec<u8>> {
}
}

pub fn send_http_request(req: Request<String>) -> Result<Response<Vec<u8>>, HttpRequestError> {
pub fn send_http_request<T>(req: Request<T>) -> Result<Response<Vec<u8>>, HttpRequestError>
where
T: Into<Vec<u8>>,
{
let method = match *req.method() {
Method::GET => HttpMethod::Get,
Method::POST => HttpMethod::Get,
Expand All @@ -50,10 +53,10 @@ pub fn send_http_request(req: Request<String>) -> Result<Response<Vec<u8>>, Http
.collect::<Vec<(&str, &str)>>();

let uri = req.uri().to_string();
let body = req.into_body();
let body: Vec<u8> = req.into_body().into();

let request = HttpRequest {
body: Some(body.as_bytes()),
body: Some(body.as_slice()),
headers: &headers_slice,
method,
params: &[],
Expand Down

0 comments on commit 6b6efab

Please sign in to comment.