reset-recognizer

Crates.ioreset-recognizer
lib.rsreset-recognizer
version0.8.0
sourcesrc
created_at2019-09-16 19:32:26.703096
updated_at2020-01-21 20:50:03.408172
descriptionA RegexSet based route recognizer
homepage
repositoryhttps://github.com/kardeiz/reset-router
max_upload_size
id165254
size15,341
Jacob Brown (kardeiz)

documentation

README

reset-recognizer

Docs Crates.io

A fast RegexSet based path router, in the style of route-recognizer.

reset-router, a higher level path router for use with Hyper 0.13, uses this library internally.

Usage:

let router = reset_recognizer::Router::build()
    .add(r"^/posts/(.+)/comments/(.+)$", "comment".to_string())
    .add(r"^/posts/(.+)/comments$", "comments".to_string())
    .add(r"^/posts/(.+)$", "post".to_string())
    .add(r"^/posts$", "posts".to_string())
    .add(r"^/comments$", "comments2".to_string())
    .add(r"^/comments/(.+)$", "comment2".to_string())
    .add_with_priority(r"^/(.+)$", 1, "not_found".to_string())
    .finish()?;

let matched = router.recognize("/posts/100/comments/200")?;

let (post_id, comment_id) = matched.captures.parsed::<(i32, i32)>()?;

println!("{:?}", (&matched.handler, &post_id, &comment_id));

Current version: 0.8.0

License: MIT

Commit count: 88

cargo fmt