Crates.io | synchronous-server |
lib.rs | synchronous-server |
version | 0.1.12 |
source | src |
created_at | 2023-12-12 12:05:24.216594 |
updated_at | 2024-04-02 05:23:15.223472 |
description | Low level synchronous server |
homepage | |
repository | https://github.com/kolserdav/synchronous-server |
max_upload_size | |
id | 1066303 |
size | 19,373 |
This is a Rust crate called synchronous-server, designed to provide reliable and efficient access services for your well-needed use cases. Our crate is built with synchronous communication in mind, ensuring that all requests are handled sequentially and without any asynchronous overhead.
To use this crate, you'll need Rust and Cargo installed. Then, follow these steps:
synchronous-server
:cargo add synchronous-server
use synchronous_server::listen;
Server
instance with the request handler:use std::io::Result;
use synchronous_server::{
http::{
headers::{Header, Headers},
status::Status,
}, listen
};
pub fn main() -> Result<()> {
let res = listen("0.0.0.0:4001", |d| {
println!("{:?}", d);
let result = "hello world".to_string();
let code = 200;
let headers = Headers::new_request(
Status::new(code).to_full_string().as_str(),
vec![
Header {
name: "Content-Type".to_string(),
value: "text/plain".to_string(),
},
Header {
name: "Custom-Header".to_string(),
value: "Hello World!".to_string(),
},
],
);
Ok((result, code, headers))
});
if let Err(err) = res {
println!("Failed to listen server: {:?}", err);
}
Ok(())
}
This package follows the Semantic Versioning (SemVer) scheme. See the CHANGELOG for release history.