| Crates.io | wasm-http-hyper |
| lib.rs | wasm-http-hyper |
| version | 0.2.1 |
| created_at | 2025-02-10 13:03:06.442909+00 |
| updated_at | 2025-02-12 16:11:59.248399+00 |
| description | A Rust WebAssembly library that provides seamless integration between Node.js's IncomingMessage and Rust's hyper::Request |
| homepage | https://github.com/forgen-org/wasm-http-hyper |
| repository | https://github.com/forgen-org/wasm-http-hyper |
| max_upload_size | |
| id | 1550021 |
| size | 16,675 |
A Rust WebAssembly library that provides seamless integration between Node.js's IncomingMessage and Rust's hyper::Request. This library allows you to parse Node.js HTTP requests in your Rust WASM code using the familiar hyper interface.
IncomingMessage to hyper::RequestAdd this to your Cargo.toml:
[dependencies]
wasm-http-hyper = "0.1.0"
use wasm_bindgen::prelude::*;
use wasm_http_hyper::IncomingMessage;
#[wasm_bindgen(js_name = "parseBody")]
pub async fn parse_body(incoming_message: IncomingMessage) -> String {
let request = incoming_message.parse().await;
String::from_utf8(request.body().to_vec()).unwrap_or_default()
}
import { parseBody } from "./pkg/your_wasm_package.js";
import http from "node:http";
const server = http.createServer(async (req, res) => {
res.end(await parseBody(req));
});
server.listen(3000, () => {
console.log("Server running at http://localhost:3000/");
});
The library provides a bridge between Node.js's HTTP request handling and Rust's hyper ecosystem:
IncomingMessage object as inputhyper::Request objectcargo install wasm-pack
wasm-pack build --target nodejs
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.