refactor(routes): clean RESTful route table; content negotiation at /users/{username}
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{handlers::*, openapi, state::AppState};
|
||||
use axum::{
|
||||
routing::{delete, get, post, put},
|
||||
routing::{delete, get, patch, post, put},
|
||||
Router,
|
||||
};
|
||||
|
||||
@@ -11,33 +11,38 @@ pub fn router() -> Router<AppState> {
|
||||
// auth
|
||||
.route("/auth/register", post(auth::post_register))
|
||||
.route("/auth/login", post(auth::post_login))
|
||||
// users — static paths before parameterised
|
||||
// users — static before parameterised
|
||||
.route("/users", get(users::get_users))
|
||||
.route("/users/count", get(users::get_user_count))
|
||||
.route(
|
||||
"/users/me",
|
||||
get(users::get_me)
|
||||
.patch(users::patch_profile)
|
||||
.put(users::patch_profile),
|
||||
)
|
||||
.route("/users/me/following-list", get(users::get_me_following))
|
||||
.route("/users/lookup", get(users::lookup_handler))
|
||||
.route("/users/me", get(users::get_me).patch(users::patch_profile))
|
||||
.route("/users/me/following", get(users::get_me_following))
|
||||
.route("/users/me/top-friends", put(social::put_top_friends))
|
||||
// /users/{username} is owned by the AP router (returns AP actor JSON for federation).
|
||||
// The REST user profile lives at /users/{username}/profile to avoid the conflict.
|
||||
.route("/users/{username}/profile", get(users::get_user))
|
||||
.route("/users/{username}", get(users::get_user))
|
||||
.route(
|
||||
"/users/{username}/top-friends",
|
||||
get(social::get_top_friends_handler),
|
||||
)
|
||||
// follows & blocks (use {id} param)
|
||||
.route(
|
||||
"/users/{id}/follow",
|
||||
"/users/{username}/follow",
|
||||
post(social::post_follow).delete(social::delete_follow),
|
||||
)
|
||||
.route(
|
||||
"/users/{id}/block",
|
||||
"/users/{username}/block",
|
||||
post(social::post_block).delete(social::delete_block),
|
||||
)
|
||||
.route(
|
||||
"/users/{username}/followers",
|
||||
get(feed::get_followers_handler),
|
||||
)
|
||||
.route(
|
||||
"/users/{username}/following",
|
||||
get(feed::get_following_handler),
|
||||
)
|
||||
.route(
|
||||
"/users/{username}/thoughts",
|
||||
get(feed::user_thoughts_handler),
|
||||
)
|
||||
// thoughts
|
||||
.route("/thoughts", post(thoughts::post_thought))
|
||||
.route(
|
||||
@@ -60,29 +65,16 @@ pub fn router() -> Router<AppState> {
|
||||
.route("/feed", get(feed::home_feed))
|
||||
.route("/feed/public", get(feed::public_feed))
|
||||
.route("/search", get(feed::search_handler))
|
||||
.route(
|
||||
"/users/{username}/follower-list",
|
||||
get(feed::get_followers_handler),
|
||||
)
|
||||
.route(
|
||||
"/users/{username}/following-list",
|
||||
get(feed::get_following_handler),
|
||||
)
|
||||
.route(
|
||||
"/users/{username}/thoughts",
|
||||
get(feed::user_thoughts_handler),
|
||||
)
|
||||
.route("/tags/popular", get(feed::get_popular_tags))
|
||||
.route("/tags/{name}", get(feed::tag_thoughts_handler))
|
||||
// notifications
|
||||
.route("/notifications", get(notifications::list_notifications))
|
||||
.route(
|
||||
"/notifications/read-all",
|
||||
post(notifications::mark_all_read),
|
||||
"/notifications",
|
||||
get(notifications::list_notifications).patch(notifications::mark_all_read),
|
||||
)
|
||||
.route(
|
||||
"/notifications/{id}/read",
|
||||
post(notifications::mark_notification_read),
|
||||
"/notifications/{id}",
|
||||
patch(notifications::mark_notification_read),
|
||||
)
|
||||
// api keys
|
||||
.route(
|
||||
|
||||
Reference in New Issue
Block a user