WHDP - Wizards hypermedia protocol parser
A library to parse the raw string
into a workable type and vice versa.

Documentation:
Explanation:
Http is a text-based protocol. It follows a rather simple format
Requests:
Method Request-URI HTTP-Version CRLF
headers CRLF
message-body
Response:
HTTP-Version Status-Code Reason-Phrase CRLF
headers CRLF
message-body
Usage:
Import the library into your Cargo.toml
[dependencies]
whdp = "1.2.0"
Then just use the TryRequest trait to parse it to a Request
use std::io::Write;
use std::net::TcpListener;
use whdp::{Response, TryRequest};
fn main() {
let server = TcpListener::bind("0.0.0.0:8080").unwrap();
let mut resp = Response::default();
for inco in server.incoming() {
let mut inco = inco.unwrap();
println!("{}", inco.try_to_request().unwrap()); let _ = inco.write_all(resp.to_string().as_bytes());
}
}
And / Or if you want to create a Response use the ResponseBuilder or the resp_presets module
use std::io::Write;
use std::net::TcpListener;
use whdp::{HttpVersion, ResponseBuilder};
use whdp::presets::ok;
fn main() {
let server = TcpListener::bind("0.0.0.0:8080").unwrap();
let resp = ResponseBuilder::new()
.with_body("Hello, World".into())
.with_status(ok())
.with_version(HttpVersion::OnePointOne)
.with_empty_headers()
.build().unwrap();
for inco in server.incoming() {
let mut inco = inco.unwrap();
let _ = inco.write_all(resp.to_string().as_bytes());
}
}