diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-27 00:12:01 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-27 00:12:01 +0100 |
commit | ea32a813a7847732e33f42c40a49c5136562b0d4 (patch) | |
tree | 42a59419da0ff3b498dce051d7b030c4c4a7d240 /src/dav | |
parent | 3d3fd80629c804b0593692318a94dc9f344936fd (diff) | |
download | aerogramme-ea32a813a7847732e33f42c40a49c5136562b0d4.tar.gz aerogramme-ea32a813a7847732e33f42c40a49c5136562b0d4.zip |
basic router, define URI pattern
Diffstat (limited to 'src/dav')
-rw-r--r-- | src/dav/mod.rs | 9 |
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!")))) |