use crate::handler::analysis::code_activity::code_activity; use crate::handler::analysis::contributors::contributors; use crate::handler::analysis::languages::languages; use crate::handler::analysis::languages_read::languages_read; use crate::handler::archives::create::create_archive; use crate::handler::archives::create_bundle::create_bundle; use crate::handler::archives::download::get_archive; use crate::handler::blame::blame as blame_handler; use crate::handler::blobs::content::blob_content; use crate::handler::blobs::list_lfs_pointers::list_lfs_pointers; use crate::handler::blobs::metadata::blob_metadata; use crate::handler::branches::create::create_branch as branch_create; use crate::handler::branches::delete::delete_branch as branch_delete; use crate::handler::branches::get::get_branch as branch_get; use crate::handler::branches::list::list_branches as branch_list; use crate::handler::branches::rename::rename_branch as branch_rename; use crate::handler::branches::set_default::set_default_branch as branch_set_default; use crate::handler::code_comments::create_code_comment::create_code_comment; use crate::handler::code_comments::list_code_comments::list_code_comments; use crate::handler::code_comments::modify::{delete_code_comment, update_code_comment}; use crate::handler::code_comments::resolve_code_comment::{ resolve_code_comment, unresolve_code_comment, }; use crate::handler::commits::get::get_commit; use crate::handler::commits::is_ancestor::is_ancestor; use crate::handler::commits::list::list_commits; use crate::handler::commits::list_commit_statuses::list_commit_statuses; use crate::handler::commits::rev_parse::rev_parse; use crate::handler::commits::set_commit_status::set_commit_status; use crate::handler::commits::stats::commit_stats; use crate::handler::commits::sync_commit::sync_commit; use crate::handler::conflicts::detail::conflict_detail; use crate::handler::conflicts::get_conflicts::get_conflicts; use crate::handler::content::caller_signature::caller_signature; use crate::handler::content::commit_object::commit_object; use crate::handler::content::write_blob::write_blob; use crate::handler::content::write_tree_from_files::write_tree_from_files; use crate::handler::diffs::for_commit::diff_for_commit; use crate::handler::diffs::get_diff::get_diff; use crate::handler::diffs::range_diff::range_diff; use crate::handler::diffs::raw::diff_raw; use crate::handler::hooks::execute_script::execute_script; use crate::handler::lfs::cleanup_unreferenced::cleanup_unreferenced; use crate::handler::lfs::list_locks::list_locks; use crate::handler::lfs::lock::lock; use crate::handler::lfs::unlock::unlock as unlock_by_path; use crate::handler::lfs::verify_locks::verify_locks; use crate::handler::licenses::{get_license, list_licenses, upsert_license}; use crate::handler::maintenance::fsck::fsck; use crate::handler::maintenance::prune::prune; use crate::handler::packs::ingest::ingest as pack_ingest; use crate::handler::packs::repack::repack as pack_repack; use crate::handler::packs::stats::stats as pack_stats; use crate::handler::patches::apply::patch_apply; use crate::handler::patches::generate::patch_generate; use crate::handler::patches::parse::patch_parse; use crate::handler::path_log::path_log; use crate::handler::refs::branches::refs_branches; use crate::handler::refs::delete::refs_delete; use crate::handler::refs::filtered::refs_list_filtered as filtered; use crate::handler::refs::get::refs_get; use crate::handler::refs::head::refs_head; use crate::handler::refs::is_object_in_ref::refs_is_object_in_ref as is_object_in_ref; use crate::handler::refs::list::refs_list; use crate::handler::refs::resolve::refs_resolve; use crate::handler::refs::update::refs_update; use crate::handler::releases::create_release::create_release; use crate::handler::releases::delete_release::delete_release; use crate::handler::releases::get_release::get_release; use crate::handler::releases::list_releases::list_releases; use crate::handler::releases::update_release::update_release; use crate::handler::remotes::add::upsert_remote; use crate::handler::remotes::clone_import::clone_import as remote_clone_import; use crate::handler::remotes::fetch::fetch as remote_fetch; use crate::handler::remotes::list::list_remotes; use crate::handler::remotes::push::push as remote_push; use crate::handler::remotes::remove::remove as remote_remove; use crate::handler::repos::archive::{archive_repo as repo_archive, unarchive_repo}; use crate::handler::repos::create::create_repo as repo_create; use crate::handler::repos::get::get_repo as repo_get; use crate::handler::repos::list::list_repos as repo_list; use crate::handler::repos::update::update_repo as repo_update; use crate::handler::signatures::verify_commit::verify_commit; use crate::handler::signatures::verify_tag::verify_tag; use crate::handler::stars::{list_stargazers, star_repo, unstar_repo}; use crate::handler::submodules::list::submodule_list as submodules_list; use crate::handler::submodules::resolve::submodule_resolve as submodules_resolve; use crate::handler::tags::create::create_tag as tag_create; use crate::handler::tags::delete::delete_tag as tag_delete; use crate::handler::tags::get::get_tag as tag_get; use crate::handler::tags::list::list_tags as tag_list; use crate::handler::topics::{ add_topic_to_repo, create_topic, get_topic, list_repo_topics, list_repos_by_topic, list_topics, remove_topic_from_repo, }; use crate::handler::trees::read::get_tree; use crate::handler::watches::{list_watchers, upsert_watch}; use crate::handler::whitelists::{ add_branch_whitelist, add_tag_whitelist, list_branch_whitelists, list_tag_whitelists, remove_branch_whitelist, remove_tag_whitelist, }; use crate::service::GitService; use api::http::Router; use api::http::routing::{delete, get, post, put}; pub fn router(_service: GitService) -> Router { Router::new() .nest("/repos", { let __inline = || -> Router { Router::new() .route("/{space_name}", post(repo_create).get(repo_list)) .route( "/{space_name}/{repo_name}", get(repo_get).patch(repo_update), ) .route("/{space_name}/{repo_name}/archive", post(repo_archive)) .route("/{space_name}/{repo_name}/unarchive", post(unarchive_repo)) .route( "/{space_name}/{repo_name}/branches", get(branch_list).post(branch_create), ) .route( "/{space_name}/{repo_name}/branches/{name}", get(branch_get).delete(branch_delete).patch(branch_rename), ) .route( "/{space_name}/{repo_name}/branches/{name}/default", put(branch_set_default), ) .route( "/{space_name}/{repo_name}/tags", get(tag_list).post(tag_create), ) .route( "/{space_name}/{repo_name}/tags/{name}", get(tag_get).delete(tag_delete), ) .route("/{space_name}/{repo_name}/commits", get(list_commits)) .route( "/{space_name}/{repo_name}/commits/{revision}", get(get_commit), ) .route("/{space_name}/{repo_name}/commits/stats", get(commit_stats)) .route( "/{space_name}/{repo_name}/commits/ancestor", get(is_ancestor), ) .route("/{space_name}/{repo_name}/rev/{revision}", get(rev_parse)) .route( "/{space_name}/{repo_name}/commit-statuses", post(set_commit_status), ) .route( "/{space_name}/{repo_name}/commit-statuses/{sha}", get(list_commit_statuses), ) .route( "/{space_name}/{repo_name}/code-comments", get(list_code_comments).post(create_code_comment), ) .route( "/{space_name}/{repo_name}/code-comments/{comment_id}", api::http::routing::patch(update_code_comment).delete(delete_code_comment), ) .route( "/{space_name}/{repo_name}/code-comments/{comment_id}/resolve", put(resolve_code_comment).delete(unresolve_code_comment), ) .route( "/{space_name}/{repo_name}/releases", get(list_releases).post(create_release), ) .route( "/{space_name}/{repo_name}/releases/{tag}", get(get_release) .patch(update_release) .delete(delete_release), ) .route("/{space_name}/{repo_name}/tree/{revision}", get(get_tree)) .route("/{space_name}/{repo_name}/path-log", get(path_log)) .route( "/{space_name}/{repo_name}/blobs/{oid}/metadata", get(blob_metadata), ) .route( "/{space_name}/{repo_name}/blobs/{oid}/content", get(blob_content), ) .route( "/{space_name}/{repo_name}/lfs-pointers", get(list_lfs_pointers), ) .route("/{space_name}/{repo_name}/blame", get(blame_handler)) .route("/{space_name}/{repo_name}/submodules", get(submodules_list)) .route( "/{space_name}/{repo_name}/submodules/resolve", get(submodules_resolve), ) .route( "/{space_name}/{repo_name}/signatures/commit/{sha}", get(verify_commit), ) .route( "/{space_name}/{repo_name}/signatures/tag/{name}", get(verify_tag), ) .route("/{space_name}/{repo_name}/diff", get(get_diff)) .route("/{space_name}/{repo_name}/diff/raw", get(diff_raw)) .route( "/{space_name}/{repo_name}/diff/for-commit/{commit}", get(diff_for_commit), ) .route("/{space_name}/{repo_name}/diff/range", get(range_diff)) .route( "/{space_name}/{repo_name}/patch/generate", get(patch_generate), ) .route("/utils/patch/parse", post(patch_parse)) .route("/utils/commit-signature", post(caller_signature)) .route("/{space_name}/{repo_name}/conflicts", get(get_conflicts)) .route( "/{space_name}/{repo_name}/conflicts/detail", get(conflict_detail), ) .route( "/{space_name}/{repo_name}/remotes/import", post(remote_clone_import), ) .route( "/{space_name}/{repo_name}/remotes/fetch", post(remote_fetch), ) .route("/{space_name}/{repo_name}/remotes/push", post(remote_push)) .route( "/{space_name}/{repo_name}/remotes/{name}", put(upsert_remote).delete(remote_remove), ) .route("/{space_name}/{repo_name}/remotes", get(list_remotes)) .route( "/{space_name}/{repo_name}/lfs/locks", get(list_locks).post(lock).delete(unlock_by_path), ) .route( "/{space_name}/{repo_name}/lfs/locks/verify", post(verify_locks), ) .route( "/{space_name}/{repo_name}/lfs/locks/{lock_id}", delete(crate::handler::lfs::unlock_by_id::unlock_by_id), ) .route( "/{space_name}/{repo_name}/hooks/{script}", post(execute_script), ) .route( "/{space_name}/{repo_name}/analysis/languages", get(languages_read).post(languages), ) .route( "/{space_name}/{repo_name}/analysis/contributors", get(contributors), ) .route( "/{space_name}/{repo_name}/analysis/code-activity", get(code_activity), ) .route("/{space_name}/{repo_name}/archives", post(create_archive)) .route( "/{space_name}/{repo_name}/archives/{revision}", get(get_archive), ) .route( "/{space_name}/{repo_name}/archives/bundle", post(create_bundle), ) .route( "/{space_name}/{repo_name}/star", put(star_repo).delete(unstar_repo), ) .route("/{space_name}/{repo_name}/stargazers", get(list_stargazers)) .route("/{space_name}/{repo_name}/watch", put(upsert_watch)) .route("/{space_name}/{repo_name}/watchers", get(list_watchers)) .route("/{space_name}/{repo_name}/topics", get(list_repo_topics)) .route( "/{space_name}/{repo_name}/topics/{topic_name}", put(add_topic_to_repo).delete(remove_topic_from_repo), ) .route( "/{space_name}/{repo_name}/branch-protection", get(crate::handler::branch_protection::list_policies::list_policies) .post(crate::handler::branch_protection::create_policy::create_policy), ) .route( "/{space_name}/{repo_name}/branch-protection/{policy_id}", get(crate::handler::branch_protection::get_policy::get_policy) .patch(crate::handler::branch_protection::update_policy::update_policy) .delete(crate::handler::branch_protection::delete_policy::delete_policy), ) .route( "/{space_name}/{repo_name}/branch-protection/{policy_id}/whitelists", post(add_branch_whitelist).get(list_branch_whitelists), ) .route( "/{space_name}/{repo_name}/branch-protection/{policy_id}/whitelists/{whitelist_id}", delete(remove_branch_whitelist), ) .route( "/{space_name}/{repo_name}/tag-protection", get(crate::handler::tag_protection::list_policies::list_policies) .post(crate::handler::tag_protection::create_policy::create_policy), ) .route( "/{space_name}/{repo_name}/tag-protection/{policy_id}", get(crate::handler::tag_protection::get_policy::get_policy) .patch(crate::handler::tag_protection::update_policy::update_policy) .delete(crate::handler::tag_protection::delete_policy::delete_policy), ) .route( "/{space_name}/{repo_name}/tag-protection/{policy_id}/whitelists", post(add_tag_whitelist).get(list_tag_whitelists), ) .route( "/{space_name}/{repo_name}/tag-protection/{policy_id}/whitelists/{user_id}", delete(remove_tag_whitelist), ) .nest( "/{space_name}/{repo_name}/html", crate::handler::html::router(), ) }; __inline() }) .nest("/topics", { let __inline = || -> Router { Router::new() .route("/", post(create_topic).get(list_topics)) .route("/{name}", get(get_topic)) .route("/{name}/repos", get(list_repos_by_topic)) }; __inline() }) .nest("/licenses", { let __inline = || -> Router { Router::new() .route("/", get(list_licenses)) .route("/{name}", get(get_license)) }; __inline() }) } pub fn internal_router(_service: GitService) -> Router { Router::new() .nest("/repos", { let __inline = || -> Router { Router::new() .route("/{space_name}/{repo_name}/refs", get(refs_list)) .route("/{space_name}/{repo_name}/refs/head", get(refs_head)) .route( "/{space_name}/{repo_name}/refs/branches", get(refs_branches), ) .route("/{space_name}/{repo_name}/refs/filtered", get(filtered)) .route( "/{space_name}/{repo_name}/refs/contains", get(is_object_in_ref), ) .route( "/{space_name}/{repo_name}/refs/{name}", get(refs_get).patch(refs_update).delete(refs_delete), ) .route( "/{space_name}/{repo_name}/refs/{name}/resolve", get(refs_resolve), ) .route( "/{space_name}/{repo_name}/commits/{revision}/sync", post(sync_commit), ) .route("/{space_name}/{repo_name}/patch/apply", post(patch_apply)) .route("/{space_name}/{repo_name}/packs/stats", get(pack_stats)) .route("/{space_name}/{repo_name}/packs/ingest", post(pack_ingest)) .route("/{space_name}/{repo_name}/packs/repack", post(pack_repack)) .route("/{space_name}/{repo_name}/maintenance/prune", post(prune)) .route("/{space_name}/{repo_name}/maintenance/fsck", post(fsck)) .route( "/{space_name}/{repo_name}/lfs/cleanup", post(cleanup_unreferenced), ) .route("/{space_name}/{repo_name}/contents/blobs", post(write_blob)) .route( "/{space_name}/{repo_name}/contents/trees", post(write_tree_from_files), ) .route( "/{space_name}/{repo_name}/contents/commits", post(commit_object), ) }; __inline() }) .merge({ let __inline = || -> Router { Router::new().route("/licenses/{name}", put(upsert_license)) }; __inline() }) }