route-pattern

Crates.ioroute-pattern
lib.rsroute-pattern
version0.2.0
sourcesrc
created_at2022-11-08 18:25:05.64701
updated_at2022-11-23 17:38:21.417823
descriptionA parser and matcher for route patterns
homepage
repositoryhttps://github.com/jondot/route-pattern
max_upload_size
id708189
size17,282
Dotan J. Nahum (jondot)

documentation

https://docs.rs/route-pattern/

README

Route Pattern

github crates.io docs.rs build status

A parser and matcher for a popular way to create route patterns.

Patterns like these that include regular expressions, delimited in this case by { and }:

/users/{[0-9]+}/update

Supports nested curlies here (inner curlies are serving the regular expression):

/users/{[0-9]{1,8}}/update

It lets you:

  • Choose your delimiters: {, } or <, > or others
  • Compile into a Regex or try a match

Dependency

[dependencies]
route-pattern = "0.1.0"

For most recent version see crates.io

Usage

let answer = route_pattern::is_match("foo/{b{1,4}}/{[0-9]+}", '{', '}', "foo/bbb/123")?

Or get a Regex and use it later

let re = route_pattern::compile("foo/{b{1,4}}/{[0-9]+}", '{', '}')?;

Copyright

Copyright (c) 2022 @jondot. See LICENSE for further details.

Commit count: 9

cargo fmt