mirror of
https://github.com/zerotier/ratpack.git
synced 2026-05-22 16:27:23 -07:00
fix some issues resolving the root url
Signed-off-by: Erik Hollensbe <linux@hollensbe.org>
This commit is contained in:
+2
-2
@@ -147,9 +147,9 @@ impl<S: 'static + Clone + Send, T: TransientState + 'static + Clone + Send> App<
|
||||
.status(sc)
|
||||
.body(Body::default())
|
||||
.unwrap()),
|
||||
Error::InternalServerError(_) => Ok(Response::builder()
|
||||
Error::InternalServerError(e) => Ok(Response::builder()
|
||||
.status(StatusCode::INTERNAL_SERVER_ERROR)
|
||||
.body(Body::default())
|
||||
.body(Body::from(e.to_string()))
|
||||
.unwrap()),
|
||||
},
|
||||
}
|
||||
|
||||
+12
-1
@@ -64,11 +64,16 @@ impl Path {
|
||||
}
|
||||
|
||||
pub(crate) fn extract(&self, provided: String) -> Result<Params, Error> {
|
||||
if (provided == "" || provided == "/") && self.eq(&Self::default()) {
|
||||
return Ok(Params::default());
|
||||
}
|
||||
|
||||
let mut params = Params::default();
|
||||
|
||||
let parts: Vec<String> = provided
|
||||
.split("/")
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
let mut params = Params::default();
|
||||
|
||||
if parts.len() != self.0.len() {
|
||||
return Err(Error::new("invalid parameters"));
|
||||
@@ -168,6 +173,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_path() {
|
||||
use super::Path;
|
||||
use crate::Params;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
let path = Path::new("/abc/def/ghi".to_string());
|
||||
@@ -201,6 +207,11 @@ mod tests {
|
||||
"/abc/:wooble/:wakka/jkl".to_string()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
Path::new("/".to_string()).extract("/".to_string()).unwrap(),
|
||||
Params::default()
|
||||
);
|
||||
|
||||
assert_eq!(Path::default().to_string(), "/".to_string());
|
||||
|
||||
let path = Path::new("/".to_string());
|
||||
|
||||
Reference in New Issue
Block a user