rede_parser

Crates.iorede_parser
lib.rsrede_parser
version0.2.2
sourcesrc
created_at2024-04-03 16:49:59.621658
updated_at2024-10-01 19:23:10.48866
descriptionParser in charge of modeling Rede's files
homepagehttps://rede.sotoestevez.dev/
repositoryhttps://github.com/kriogenia/rede
max_upload_size
id1195231
size27,159
Soto Estévez (kriogenia)

documentation

https://docs.rs/rede_parser

README

Rede Parser

Library crate to receive the content of Rede's files and generate the requests or environments to use in the command-line binary. It can be used on its own to implement Rede's format in other projects or implementations.

Usage

The library offers the function rede_parser::parse_request to convert a given string into a valid rede_parser::Request.

let toml = r#"
[http]
method = "POST"
url = "http://localhost:8080/note"

[headers]
Content-Type = "application/json"

[body]
raw = """
{
  "title": "Implement rede_parser" ,
  "description": "Implement it following the example
}
"""
"#;

let request = rede_parser::parse_request(toml)?;
assert_eq!(request.method, Method::POST);
assert_eq!(request.url, "http://localhost:8080/note");
assert_eq!(request.headers["Content-Type"], "application/json");
if let Body::Raw { content, mime } = &request.body {
  assert_eq!(mime, &"text/plain; charset=utf-8");
  println!("{}", &request.body);
}
Commit count: 234

cargo fmt