diff --git a/examples/porting-may_minihttp/Cargo.toml b/examples/porting-may_minihttp/Cargo.toml new file mode 100644 index 0000000..aa11741 --- /dev/null +++ b/examples/porting-may_minihttp/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "porting-may_minihttp" +version = "0.1.0" +description = "Porting of the crate may_minihttp" +license = "MIT" +edition = "2021" +exclude = ["index.node"] + +[lib] +crate-type = ["cdylib"] + +[dependencies] +neon = "1.1.0-alpha.1" +may_minihttp = "0.1.11" diff --git a/examples/porting-may_minihttp/README.md b/examples/porting-may_minihttp/README.md new file mode 100644 index 0000000..6e5c0f9 --- /dev/null +++ b/examples/porting-may_minihttp/README.md @@ -0,0 +1,19 @@ +# porting-may_minihttp + +Porting of the crate [may_minihttp](https://crates.io/crates/may_minihttp) ([GitHub repository](https://github.com/Xudong-Huang/may_minihttp)). + +## Usage + +```js +const { HttpServer, HttpService, Request, Response } = require("."); + +class HelloWorld extends HttpService { + call(_req: Request, res: Response) { + res.body("Hello, world!"); + } +} + +const server = HttpServer(HelloWorld).start("0.0.0.0:8080").unwrap(); + +server.join().unwrap(); +``` diff --git a/examples/porting-may_minihttp/package.json b/examples/porting-may_minihttp/package.json new file mode 100644 index 0000000..77ca6b6 --- /dev/null +++ b/examples/porting-may_minihttp/package.json @@ -0,0 +1,27 @@ +{ + "name": "porting-may_minihttp", + "version": "0.1.0", + "description": "Porting of the crate may_minihttp", + "main": "index.node", + "scripts": { + "build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics", + "install": "npm run build", + "test": "cargo test" + }, + "license": "MIT", + "devDependencies": { + "cargo-cp-artifact": "^0.1.9" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/neon-bindings/examples.git" + }, + "keywords": [ + "Neon", + "Examples" + ], + "bugs": { + "url": "https://github.com/neon-bindings/examples/issues" + }, + "homepage": "https://github.com/neon-bindings/examples#readme" +} diff --git a/examples/porting-may_minihttp/src/lib.rs b/examples/porting-may_minihttp/src/lib.rs new file mode 100644 index 0000000..d4d3df5 --- /dev/null +++ b/examples/porting-may_minihttp/src/lib.rs @@ -0,0 +1,2 @@ +use neon::prelude::*; +use may_minihttp::{BodyReader, HttpServer, HttpService, HttpServiceFactorye, Request, Response};