move out the files api to a different folder

This commit is contained in:
blek 2023-10-22 15:16:13 +10:00
parent 5d05f7190a
commit f8172d7e61
Signed by: blek
GPG Key ID: 14546221E3595D0C
3 changed files with 5 additions and 4 deletions

View File

@ -1,11 +1,11 @@
use warp::{reply::Reply, reject::Rejection, Filter}; use warp::{reply::Reply, reject::Rejection, Filter};
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use self::get_all::get_all_f; use self::files::get_all::get_all_f;
use super::state::SharedState; use super::state::SharedState;
mod get_all; mod files;
mod types; mod types;
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]

View File

@ -0,0 +1 @@
pub mod get_all;

View File

@ -2,14 +2,14 @@ use warp::{reply::{Reply, json}, reject::Rejection, Filter, http::StatusCode};
use crate::web::{state::SharedState, rejection::HttpReject}; use crate::web::{state::SharedState, rejection::HttpReject};
use super::types::ErrorMessage; use super::super::types::{ErrorMessage, Error};
pub async fn get_all(state: SharedState) -> Result<Box<dyn Reply>, Rejection> { pub async fn get_all(state: SharedState) -> Result<Box<dyn Reply>, Rejection> {
if ! state.config.api.enabled { if ! state.config.api.enabled {
return Ok( return Ok(
Box::new( Box::new(
warp::reply::with_status( warp::reply::with_status(
json(&ErrorMessage::new(super::types::Error::APIDisabled)), json(&ErrorMessage::new(Error::APIDisabled)),
StatusCode::SERVICE_UNAVAILABLE StatusCode::SERVICE_UNAVAILABLE
) )
) )