gourami

[UNMAINTAINED] Activitypub server in Rust
Log | Files | Refs | README | LICENSE

commit 60e1c13c78a97b60d90b50b57e39f941d29c433f
parent 696391014963a7ee812c52fea50920ef2eafd696
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Fri,  5 Jun 2020 17:37:59 -0500

Add backwards-compatible alias

Not really sure why

Diffstat:
Msrc/routes.rs | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/routes.rs b/src/routes.rs @@ -62,13 +62,32 @@ pub async fn run_server() { |_| reply::json(&ap::server_actor_json()), // how do async work ); - // replace with timeline query let home = warp::path::end() .and(optional_session_filter()) .and(query()) .and(path::full()) .map(|user: Option<User>, params, url| render_timeline(user.clone(), &params, url, get_notes(user.is_some(), &params))); + // a bit awkward + let user_alias = warp::path!("user" / String) + .and(optional_session_filter()) + .and(query::<GetPostsParams>()) + .and(path::full()) + .map(|username: String, user: Option<User>, mut params: GetPostsParams, url| { + params.username = Some(username); + render_timeline(user.clone(), &params, url, get_notes(user.is_some(), &params)) + }); + + // a bit awkward + let note_alias = warp::path!("note" / i32) + .and(optional_session_filter()) + .and(query::<GetPostsParams>()) + .and(path::full()) + .map(|note: i32, user: Option<User>, mut params: GetPostsParams, url| { + params.note_id = Some(note); + render_timeline(user.clone(), &params, url, get_notes(user.is_some(), &params)) + }); + let user_edit_page = session_filter() .and(path!("user" / String / "edit")) .map(render_user_edit_page); @@ -148,6 +167,8 @@ pub async fn run_server() { // let api_filter = session::create_session_filter(&POOL.get()); let static_json = actor_json.or(webfinger); // rename html renders let html_renders = home + .or(note_alias) + .or(user_alias) .or(login_page) .or(register_page) .or(server_info_page)