pub fn parse_request(content: &str) -> Result<Request, Error>Expand description
Attempts to parse the given string into an HTTP request.
§Example
Passing the contents of a valid request TOML will provide a [Request]
let toml = r#"
http = { url = "http://localhost:8080", method = "GET" }
"#;
let request = rede_parser::parse_request(toml)?;
assert_eq!(request.url, "http://localhost:8080");
assert_eq!(request.method, "GET");§Errors
Some possible errors are:
- The contents are not a valid TOML file
- A required key is missing
- At least one is the wrong type
let toml = r#"
http = { url = "http://localhost:8080", method = "GET" }
query_params = { since = 1970-01-01 }
"#;
let result = rede_parser::parse_request(toml);
assert!(result.is_err());