fix(api): fix branch route order to prevent shadowing
Move all specific branch routes before /branches/{name} to prevent
route shadowing. Previously, routes like /branches/rename, /branches/move,
/branches/upstream, /branches/diff, etc. were shadowed by /branches/{name}.
This commit is contained in:
parent
1272615d50
commit
ee4ff6c752
@ -54,39 +54,17 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
||||
.route("/blob/{oid}/content", web::get().to(blob::git_blob_content))
|
||||
.route("/blob/{oid}/size", web::get().to(blob::git_blob_size))
|
||||
.route("/readme", web::get().to(blob::git_readme))
|
||||
// branch
|
||||
// branch - specific routes first, then parameterized routes
|
||||
.route("/branches", web::get().to(branch::git_branch_list))
|
||||
.route(
|
||||
"/branches/summary",
|
||||
web::get().to(branch::git_branch_summary),
|
||||
)
|
||||
.route("/branches", web::post().to(branch::git_branch_create))
|
||||
// NOTE: /branches/current MUST be before /branches/{name} to avoid being shadowed
|
||||
.route(
|
||||
"/branches/current",
|
||||
web::get().to(branch::git_branch_current),
|
||||
)
|
||||
.route("/branches/{name}", web::get().to(branch::git_branch_get))
|
||||
.route(
|
||||
"/branches/{name}",
|
||||
web::delete().to(branch::git_branch_delete),
|
||||
)
|
||||
.route(
|
||||
"/branches/{name}/exists",
|
||||
web::get().to(branch::git_branch_exists),
|
||||
)
|
||||
.route(
|
||||
"/branches/{name}/is-head",
|
||||
web::get().to(branch::git_branch_is_head),
|
||||
)
|
||||
.route(
|
||||
"/branches/{name}/upstream",
|
||||
web::get().to(branch::git_branch_upstream),
|
||||
)
|
||||
.route(
|
||||
"/branches/{name}/tracking-difference",
|
||||
web::get().to(branch::git_branch_tracking_difference),
|
||||
)
|
||||
.route(
|
||||
"/branches/remote/{name}",
|
||||
web::delete().to(branch::git_branch_delete_remote),
|
||||
@ -125,6 +103,28 @@ pub fn init_git_routes(cfg: &mut web::ServiceConfig) {
|
||||
"/branches/is-conflicted",
|
||||
web::get().to(branch::git_branch_is_conflicted),
|
||||
)
|
||||
// parameterized routes with {name}
|
||||
.route("/branches/{name}", web::get().to(branch::git_branch_get))
|
||||
.route(
|
||||
"/branches/{name}",
|
||||
web::delete().to(branch::git_branch_delete),
|
||||
)
|
||||
.route(
|
||||
"/branches/{name}/exists",
|
||||
web::get().to(branch::git_branch_exists),
|
||||
)
|
||||
.route(
|
||||
"/branches/{name}/is-head",
|
||||
web::get().to(branch::git_branch_is_head),
|
||||
)
|
||||
.route(
|
||||
"/branches/{name}/upstream",
|
||||
web::get().to(branch::git_branch_upstream),
|
||||
)
|
||||
.route(
|
||||
"/branches/{name}/tracking-difference",
|
||||
web::get().to(branch::git_branch_tracking_difference),
|
||||
)
|
||||
// commit - specific routes first, then parameterized routes
|
||||
.route("/commits", web::get().to(commit::git_commit_log))
|
||||
.route("/commits/count", web::get().to(commit::git_commit_count))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user