basic router, define URI pattern
This commit is contained in:
parent
3d3fd80629
commit
ea32a813a7
1 changed files with 7 additions and 2 deletions
|
@ -67,8 +67,13 @@ impl Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn router(req: Request<impl hyper::body::Body>) -> Result<Response<Full<Bytes>>> {
|
async fn router(req: Request<impl hyper::body::Body>) -> Result<Response<Full<Bytes>>> {
|
||||||
let url_exploded: Vec<_> = req.uri().path().split(",").collect();
|
let path_segments: Vec<_> = req.uri().path().split("/").filter(|s| *s != "").collect();
|
||||||
match url_exploded {
|
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!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
Ok(Response::new(Full::new(Bytes::from("Hello World!"))))
|
Ok(Response::new(Full::new(Bytes::from("Hello World!"))))
|
||||||
|
|
Loading…
Reference in a new issue