Skip to main content

route

Function route 

Source
pub fn route(method: &Method, path: &str, hash: &str) -> Route
Expand description

What a method request for path asks for, from a bundle whose frames’ hash is hash.

The paths it answers are /frames/<hash>/<path> and /packs/<place>, where a path is a FilePath, which can’t leave its folder; another method than GET is refused with 405, anything else with 404.

use compmd_host::{route, Refusal, Route};

let route = route(&http::Method::GET, "/frames/1df336e75685de8c/strict.html", "1df336e75685de8c");
assert!(matches!(route, Route::Frame(path) if path.as_str() == "strict.html"));
let refused = compmd_host::route(&http::Method::GET, "/frames/1df336e75685de8c/../x", "1df336e75685de8c");
assert_eq!(refused, Route::Refused(Refusal::NOT_SERVED));