Struct pencil::routing::Rule [] [src]

pub struct Rule {
    pub matcher: Matcher,
    pub methods: HashSet<Method>,
    pub endpoint: String,
    pub provide_automatic_options: bool,
}

A Rule represents one URL pattern.

Fields

matcher

The matcher is used to match the url path.

methods

A set of http methods this rule applies to.

endpoint

The endpoint for this rule.

provide_automatic_options

Methods

impl Rule

fn new(matcher: Matcher, methods: &[Method], endpoint: &str) -> Rule

Create a new Rule. Matcher basically are used to hold url regular expressions. Rule endpoint is a string that is used for URL generation. Rule methods is an array of http methods this rule applies to, if GET is present in it and HEAD is not, HEAD is added automatically.

fn matched(&self, path: String) -> Option<ViewArgs>

Check if the rule matches a given path.

Trait Implementations

Derived Implementations

impl Clone for Rule

fn clone(&self) -> Rule

fn clone_from(&mut self, source: &Self)