Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated dependencies #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pencil"
version = "0.3.0"
version = "0.4.0"
authors = ["Shipeng Feng <fsp261@gmail.com>"]
keywords = ["web", "framework"]
license = "BSD-3-Clause"
Expand All @@ -10,24 +10,20 @@ homepage = "https://github.com/fengsp/pencil"
documentation = "http://fengsp.github.io/pencil/"
description = "A micro web framework for Rust."

[features]
default = ["ssl"]
ssl = ["hyper/ssl", "formdata/ssl"]

[dependencies]
regex = "0.1.77"
regex = "0.2"
rustc-serialize = "0.3.19"
url = "1.2.1"
log = "0.3.6"
handlebars = "0.16.1"
handlebars = "0.25"
typemap = "0.3.3"
mime = "0.2.2"
mime_guess = "1.8.0"

[dependencies.hyper]
version = "0.9.10"
version = "0.10"
default_features = false

[dependencies.formdata]
version = "0.11.0"
version = "0.12"
default_features = false
16 changes: 8 additions & 8 deletions src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::collections::HashMap;
use std::collections::HashSet;
use regex::Regex;
use regex::quote as regex_quote;
use regex::escape as regex_escape;

use hyper::method::Method;

Expand Down Expand Up @@ -33,19 +33,19 @@ fn parse_rule(rule: &str) -> Vec<(Option<&str>, &str)> {
Some(caps) => {
let static_part = caps.name("static");
if static_part.is_some() {
rule_parts.push((None, static_part.unwrap()));
rule_parts.push((None, static_part.unwrap().as_str()));
}
let variable = caps.name("variable").unwrap();
let variable = caps.name("variable").unwrap().as_str();
let converter = match caps.name("converter") {
Some(converter) => { converter },
Some(converter) => { converter.as_str() },
None => { "default" },
};
if used_names.contains(variable) {
panic!("variable name {} used twice.", variable);
}
used_names.insert(variable);
rule_parts.push((Some(converter), variable));
let end = caps.pos(0).unwrap().1;
let end = caps.get(0).unwrap().end();
let (_, tail) = remaining.split_at(end);
remaining = tail;
},
Expand Down Expand Up @@ -115,7 +115,7 @@ impl<'a> From<&'a str> for Matcher {
regex_parts.push(format!("(?P<{}>{})", variable, re));
},
None => {
let escaped_variable = regex_quote(variable);
let escaped_variable = regex_escape(variable);
regex_parts.push(escaped_variable);
}
}
Expand Down Expand Up @@ -202,15 +202,15 @@ impl Rule {
match self.matcher.regex.captures(&path) {
Some(caps) => {
if let Some(suffix) = caps.name("__suffix__") {
if suffix.is_empty() {
if suffix.as_str().is_empty() {
return Some(Err(RequestSlashError));
}
}
let mut view_args: HashMap<String, String> = HashMap::new();
for variable in self.matcher.regex.capture_names() {
if let Some(variable) = variable {
if variable != "__suffix__" {
view_args.insert(variable.to_string(), caps.name(variable).unwrap().to_string());
view_args.insert(variable.to_string(), caps.name(variable).unwrap().as_str().to_string());
}
}
}
Expand Down