mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 17:08:13 +00:00
two dev handlers for testing new serialization
This commit is contained in:
1 parent
f3afc4b046
commit
6f9ea92106
7 files changed
+71
No files matched your search
+17
@@ -0,0 +1,17 @@
|
||||
use actix_web::HttpResponse;
|
||||
|
||||
use crate::http_server::common_responses::common_web_error::CommonWebError;
|
||||
|
||||
/// Dev-only endpoint that unconditionally returns a `BadInputWithSimpleMessage`
|
||||
/// so we can exercise error paths (paging, response shape, etc.) end-to-end.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
tag = "Dev",
|
||||
path = "/v1/dev/basic_input_error",
|
||||
responses(
|
||||
(status = 400, description = "Always returns this — that's the point"),
|
||||
),
|
||||
)]
|
||||
pub async fn dev_basic_input_error_handler() -> Result<HttpResponse, CommonWebError> {
|
||||
Err(CommonWebError::BadInputWithSimpleMessage("testing".to_string()))
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
use actix_web::HttpResponse;
|
||||
|
||||
use crate::http_server::common_responses::common_web_error::CommonWebError;
|
||||
|
||||
/// Dev-only endpoint that unconditionally returns a `BadInputWithSimpleMessage`
|
||||
/// so we can exercise error paths (paging, response shape, etc.) end-to-end.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
tag = "Dev",
|
||||
path = "/v1/dev/input_error",
|
||||
responses(
|
||||
(status = 400, description = "Always returns this — that's the point"),
|
||||
),
|
||||
)]
|
||||
pub async fn dev_input_error_handler() -> Result<HttpResponse, CommonWebError> {
|
||||
Err(CommonWebError::BadInputWithSimpleMessage("testing".to_string()))
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod dev_basic_input_error_handler;
|
||||
pub mod dev_input_error_handler;
|
||||
@@ -5,6 +5,7 @@ pub mod billing_fakeyou;
|
||||
pub mod characters;
|
||||
pub mod comments;
|
||||
pub mod credits;
|
||||
pub mod dev;
|
||||
pub mod download_job;
|
||||
pub mod featured_items;
|
||||
pub mod generate;
|
||||
|
||||
+2
@@ -3,6 +3,7 @@ use crate::http_server::routes::application_routes::billing_fakeyou_routes::add_
|
||||
use crate::http_server::routes::application_routes::character_routes::add_character_routes;
|
||||
use crate::http_server::routes::application_routes::comments_routes::add_comments_routes;
|
||||
use crate::http_server::routes::application_routes::credits_routes::add_credits_routes;
|
||||
use crate::http_server::routes::application_routes::dev_routes::add_dev_routes;
|
||||
use crate::http_server::routes::application_routes::featured_item_routes::add_featured_item_routes;
|
||||
use crate::http_server::routes::application_routes::generate_routes::add_generate_routes;
|
||||
use crate::http_server::routes::application_routes::job_routes::add_job_routes;
|
||||
@@ -63,6 +64,7 @@ where
|
||||
// Other useful tools
|
||||
app = add_analytics_routes(app); // /v1/analytics/...
|
||||
app = add_web_referrals_routes(app); // /v1/web_referrals/...
|
||||
app = add_dev_routes(app); // /v1/dev/... — dev-only error/response shape probes
|
||||
|
||||
// User and user-adjacent routes
|
||||
app = add_comments_routes(app); // /v1/comments/...
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
use actix_http::body::MessageBody;
|
||||
use actix_service::ServiceFactory;
|
||||
use actix_web::dev::{ServiceRequest, ServiceResponse};
|
||||
use actix_web::error::Error;
|
||||
use actix_web::{web, App, HttpResponse};
|
||||
|
||||
use crate::http_server::endpoints::dev::dev_basic_input_error_handler::dev_basic_input_error_handler;
|
||||
use crate::http_server::endpoints::dev::dev_input_error_handler::dev_input_error_handler;
|
||||
|
||||
pub fn add_dev_routes<T, B> (app: App<T>) -> App<T>
|
||||
where
|
||||
B: MessageBody,
|
||||
T: ServiceFactory<
|
||||
ServiceRequest,
|
||||
Config = (),
|
||||
Response = ServiceResponse<B>,
|
||||
Error = Error,
|
||||
InitError = (),
|
||||
>,
|
||||
{
|
||||
app.service(web::scope("/v1/dev")
|
||||
.service(web::resource("/input_error")
|
||||
.route(web::get().to(dev_input_error_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
.service(web::resource("/basic_input_error")
|
||||
.route(web::get().to(dev_basic_input_error_handler))
|
||||
.route(web::head().to(|| HttpResponse::Ok()))
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -3,6 +3,7 @@ mod billing_fakeyou_routes;
|
||||
mod character_routes;
|
||||
mod comments_routes;
|
||||
mod credits_routes;
|
||||
mod dev_routes;
|
||||
mod featured_item_routes;
|
||||
mod generate_routes;
|
||||
mod job_routes;
|
||||
|
||||
Reference in new issue
Block a user