rust-web-server 18.8.4

Single-binary web server and reverse proxy: automatic HTTPS (Let's Encrypt), HTTP/1.1, HTTP/2 and HTTP/3, load balancing, auth and rate limiting, configured in one TOML file. Also a Rust library: routing, middleware, MCP server, ORM, background jobs. No hyper, no Tower; HTTP/2 and HTTP/3 framing via h2 and quinn.
Documentation
use std::collections::HashMap;
use crate::symbol::SYMBOL;
use crate::url::URL;

/// Parser and serialiser for `application/x-www-form-urlencoded` bodies.
pub struct FormUrlEncoded;

impl FormUrlEncoded {
    /// Parses a URL-encoded body into a `HashMap` of field name → value.
    pub fn parse(data: Vec<u8>) -> Result<HashMap<String, String>, String> {
        let boxed_string = String::from_utf8(data);
        if boxed_string.is_err() {
            let message = boxed_string.err().unwrap().to_string();
            return Err(message)
        }
        let string = boxed_string.unwrap();
        let string = string.replace(|x : char | x.is_ascii_control(), SYMBOL.empty_string).trim().to_string();


        Ok(URL::parse_query(&string))
    }

    pub fn generate(map: HashMap<String, String>) -> String {
        URL::build_query(map)
    }
}