Implement all API according to swagger spec #27

Merged
blek merged 16 commits from delete-upload-api-methods into 0.2-dev 2023-12-14 11:56:46 +01:00
2 changed files with 22 additions and 11 deletions
Showing only changes of commit 3c3ca2b87a - Show all commits

View File

@ -1 +1,19 @@
use warp::{reply::{WithStatus, Json, json}, http::StatusCode};
use crate::web::state::SharedState;
use super::types::{ErrorMessage, Error};
fn check_api_enabled(state: &SharedState) -> Result<(), WithStatus<Json>> {
if ! state.config.api.enabled {
return Err(
warp::reply::with_status(
json(&ErrorMessage::new(Error::APIDisabled)),
StatusCode::SERVICE_UNAVAILABLE
)
)
}
Ok(())
}
pub mod get_all;

View File

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