Crates.io | craweb |
lib.rs | craweb |
version | 0.3.0 |
source | src |
created_at | 2022-07-11 11:05:19.439162 |
updated_at | 2022-07-25 15:11:41.781093 |
description | Multithreaded asynchronous web server, written in Rust. |
homepage | |
repository | https://gitlab.com/Pelfox/craweb |
max_upload_size | |
id | 623712 |
size | 17,729 |
Multithreaded asynchronous web server, written in Rust. And it's really fast (we are handling one request in less than 1 second)!
You can install this crate using crates.io.
[dependencies]
craweb = "*" # Or you can replace version with specific ones.
In order to start the server, you must do the following:
main.rs
file.Here's an example (as well as in the example_server in the root repository):
use std::collections::HashMap;
use std::sync::Arc;
use craweb::{
models::Response,
server::Server,
};
#[tokio::main]
async fn main() {
let mut server = Server::new(None, None, None);
server.get("/", |_| {
let mut headers = HashMap::new();
headers.insert("Content-Type", "application/json");
return Response {
content: "{\"status\": \"Hello, World!\"}",
status_code: 200,
status_message: "OK",
headers,
};
});
Arc::new(server).bind("127.0.0.1:3000").await;
}
This crate is licensed under the MIT License. You can read the full license text here.