Skip to content

kolserdav/synchronous-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

synchronous-server

License

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.

Features

  • Synchronous communication for reliable and predictable behavior
  • Customizable request and response handling logic

Getting Started

To use this crate, you'll need Rust and Cargo installed. Then, follow these steps:

  1. Install synchronous-server:
cargo add synchronous-server
  1. Import the crate in your Rust module:
use synchronous_server::listen;
  1. Create a new 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(())
}

Versioning

This package follows the Semantic Versioning (SemVer) scheme. See the CHANGELOG for release history.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages