Rusty_Express
A simple http server written in Rust and provide Express-alike APIs.
How to use
In your project's Cargo.toml
, add dependency:
[dependencies]
rusty_express = "0.2.1"
...
In src\main.rs
:
extern crate rusty_express;
use rusty_express::HttpServer;
use rusty_express::ServerDef;
use rusty_express::http::*;
use rusty_express::router::*;
fn main() {
let mut server = HttpServer::new();
server.set_pool_size(8);
server.get(RequestPath::Exact("/"), simple_response);
server.listen(8080);
}
pub fn simple_response(req: Request, resp: &mut Response) {
resp.send(String::from("Hello world from the rusty-express server!\n"));
resp.status(200);
}