feature/upstream-service #13
@@ -1 +1,2 @@
|
|||||||
|
pub mod api_error;
|
||||||
pub mod service_error;
|
pub mod service_error;
|
||||||
|
|||||||
21
apps/api/src/errors/api_error.rs
Normal file
21
apps/api/src/errors/api_error.rs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
use axum::response::IntoResponse;
|
||||||
|
|
||||||
|
use crate::errors::service_error::ServiceError;
|
||||||
|
|
||||||
|
pub enum ApiError {
|
||||||
|
ServiceError(ServiceError),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ServiceError> for ApiError {
|
||||||
|
fn from(err: ServiceError) -> Self {
|
||||||
|
ApiError::ServiceError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntoResponse for ApiError {
|
||||||
|
fn into_response(self) -> axum::response::Response {
|
||||||
|
match self {
|
||||||
|
ApiError::ServiceError(service_error) => service_error.into_response(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::service_error::ServiceError,
|
errors::{api_error::ApiError, service_error::ServiceError},
|
||||||
routes::{
|
routes::{
|
||||||
AppState,
|
AppState,
|
||||||
api::{
|
api::{
|
||||||
@@ -64,7 +64,7 @@ pub async fn get_upstream(
|
|||||||
Path(upstream_id): Path<Uuid>,
|
Path(upstream_id): Path<Uuid>,
|
||||||
Query(params): Query<GetUpstreamParams>,
|
Query(params): Query<GetUpstreamParams>,
|
||||||
State(_state): State<Arc<AppState>>,
|
State(_state): State<Arc<AppState>>,
|
||||||
) -> AxumResult<Json<UpstreamInfoResponse>, ServiceError> {
|
) -> AxumResult<Json<UpstreamInfoResponse>, ApiError> {
|
||||||
let concrete_params: ConcreteGetUpstreamParams = params.into();
|
let concrete_params: ConcreteGetUpstreamParams = params.into();
|
||||||
let upstream_service = &_state.service.nginx.get_upstream_service();
|
let upstream_service = &_state.service.nginx.get_upstream_service();
|
||||||
let upstream_info = if concrete_params.include_targets {
|
let upstream_info = if concrete_params.include_targets {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::service_error::ServiceError,
|
errors::{api_error::ApiError, service_error::ServiceError},
|
||||||
routes::{AppState, api::restricted::nginx::upstream::info::response::UpstreamTargetInfo},
|
routes::{AppState, api::restricted::nginx::upstream::info::response::UpstreamTargetInfo},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ pub async fn get_upstream_target(
|
|||||||
Path(upstream_target_id): Path<Uuid>,
|
Path(upstream_target_id): Path<Uuid>,
|
||||||
Query(params): Query<GetUpstreamTargetsParams>,
|
Query(params): Query<GetUpstreamTargetsParams>,
|
||||||
State(_state): State<Arc<AppState>>,
|
State(_state): State<Arc<AppState>>,
|
||||||
) -> AxumResult<Json<UpstreamTargetInfo>, ServiceError> {
|
) -> AxumResult<Json<UpstreamTargetInfo>, ApiError> {
|
||||||
let concrete_params: ConcreteGetUpstreamTargetsParams = params.into();
|
let concrete_params: ConcreteGetUpstreamTargetsParams = params.into();
|
||||||
let upstream_service = &_state.service.nginx.get_upstream_service();
|
let upstream_service = &_state.service.nginx.get_upstream_service();
|
||||||
let upstream_target_info = upstream_service
|
let upstream_target_info = upstream_service
|
||||||
|
|||||||
Reference in New Issue
Block a user