mirror of
https://github.com/MedzikUser/HomeDisk.git
synced 2024-08-14 21:46:53 +00:00
server(http): move nest path to api to /api/*
This commit is contained in:
parent
2d121ef5c8
commit
03afaa1b49
11 changed files with 12 additions and 18 deletions
|
@ -8,7 +8,6 @@ use homedisk_types::{
|
|||
|
||||
use crate::middleware::{create_token, validate_json};
|
||||
|
||||
/// Handle `/auth/login` requests
|
||||
pub async fn handle(
|
||||
Extension(db): Extension<Database>,
|
||||
Extension(config): Extension<Config>,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
pub mod login;
|
||||
pub mod register;
|
||||
pub mod whoami;
|
||||
mod login;
|
||||
mod register;
|
||||
mod whoami;
|
||||
|
||||
/// Handle `/api/auth/*` requests
|
||||
pub fn app() -> axum::Router {
|
||||
use axum::routing::{get, post};
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ use homedisk_types::{
|
|||
|
||||
use crate::middleware::{create_token, validate_json};
|
||||
|
||||
/// Handle `/auth/register` requests
|
||||
pub async fn handle(
|
||||
Extension(db): Extension<Database>,
|
||||
Extension(config): Extension<Config>,
|
||||
|
|
|
@ -9,7 +9,6 @@ use homedisk_types::{
|
|||
|
||||
use crate::middleware::validate_jwt;
|
||||
|
||||
/// Handle `/auth/whoami` requests
|
||||
pub async fn handle(
|
||||
db: Extension<Database>,
|
||||
config: Extension<Config>,
|
||||
|
|
|
@ -13,7 +13,6 @@ use crate::middleware::{find_user, validate_json, validate_jwt};
|
|||
|
||||
use super::validate_path;
|
||||
|
||||
/// Handle `/fs/createdir` requests
|
||||
pub async fn handle(
|
||||
Extension(db): Extension<Database>,
|
||||
Extension(config): Extension<Config>,
|
||||
|
|
|
@ -14,7 +14,6 @@ use crate::middleware::{find_user, validate_jwt};
|
|||
|
||||
use super::validate_path;
|
||||
|
||||
/// Handle `/fs/delete` requests
|
||||
pub async fn handle(
|
||||
Extension(db): Extension<Database>,
|
||||
Extension(config): Extension<Config>,
|
||||
|
|
|
@ -11,7 +11,6 @@ use crate::middleware::{find_user, validate_jwt};
|
|||
|
||||
use super::validate_path;
|
||||
|
||||
/// Handle `/fs/download` requests
|
||||
pub async fn handle(
|
||||
Extension(db): Extension<Database>,
|
||||
Extension(config): Extension<Config>,
|
||||
|
|
|
@ -32,7 +32,6 @@ fn dir_size(path: impl Into<PathBuf>) -> io::Result<u64> {
|
|||
dir_size(fs::read_dir(path.into())?)
|
||||
}
|
||||
|
||||
/// Handle `/fs/list` requests
|
||||
pub async fn handle(
|
||||
Extension(db): Extension<Database>,
|
||||
Extension(config): Extension<Config>,
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
pub mod create_dir;
|
||||
pub mod delete;
|
||||
pub mod download;
|
||||
pub mod list;
|
||||
pub mod upload;
|
||||
mod create_dir;
|
||||
mod delete;
|
||||
mod download;
|
||||
mod list;
|
||||
mod upload;
|
||||
|
||||
/// Handle `/api/fs/*` requests
|
||||
pub fn app() -> axum::Router {
|
||||
use axum::routing::{delete, get, post};
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ use crate::middleware::{find_user, validate_jwt};
|
|||
|
||||
use super::validate_path;
|
||||
|
||||
/// Handle `/fs/upload` requests
|
||||
pub async fn handle(
|
||||
Extension(db): Extension<Database>,
|
||||
Extension(config): Extension<Config>,
|
||||
|
|
|
@ -29,8 +29,8 @@ pub async fn serve_http(
|
|||
// create http Router
|
||||
let app = Router::new()
|
||||
.route("/health-check", get(health_check))
|
||||
.nest("/auth", auth::app())
|
||||
.nest("/fs", fs::app())
|
||||
.nest("/api/auth", auth::app())
|
||||
.nest("/api/fs", fs::app())
|
||||
.layer(CorsLayer::new().allow_origin(AllowOrigin::list(origins)))
|
||||
.layer(Extension(db))
|
||||
.layer(Extension(config));
|
||||
|
|
Loading…
Reference in a new issue