aboutsummaryrefslogtreecommitdiff
path: root/src/dav
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-02-27 00:12:01 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-02-27 00:12:01 +0100
commitea32a813a7847732e33f42c40a49c5136562b0d4 (patch)
tree42a59419da0ff3b498dce051d7b030c4c4a7d240 /src/dav
parent3d3fd80629c804b0593692318a94dc9f344936fd (diff)
downloadaerogramme-ea32a813a7847732e33f42c40a49c5136562b0d4.tar.gz
aerogramme-ea32a813a7847732e33f42c40a49c5136562b0d4.zip
basic router, define URI pattern
Diffstat (limited to 'src/dav')
-rw-r--r--src/dav/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dav/mod.rs b/src/dav/mod.rs
index 36d154a..d3347f3 100644
--- a/src/dav/mod.rs
+++ b/src/dav/mod.rs
@@ -67,8 +67,13 @@ impl Server {
}
async fn router(req: Request<impl hyper::body::Body>) -> Result<Response<Full<Bytes>>> {
- let url_exploded: Vec<_> = req.uri().path().split(",").collect();
- match url_exploded {
+ let path_segments: Vec<_> = req.uri().path().split("/").filter(|s| *s != "").collect();
+ match path_segments.as_slice() {
+ [] => tracing::info!("root"),
+ [ user ] => tracing::info!(user=user, "user home"),
+ [ user, coltype ] => tracing::info!(user=user, cat=coltype, "user cat of coll"),
+ [ user, coltype, colname ] => tracing::info!(user=user, cat=coltype, name=colname, "user coll"),
+ [ user, coltype, colname, member ] => tracing::info!(user=user, cat=coltype, name=colname, obj=member, "accessing file"),
_ => unimplemented!(),
}
Ok(Response::new(Full::new(Bytes::from("Hello World!"))))