mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 02:47:45 +08:00
38 lines
1.3 KiB
Rust
38 lines
1.3 KiB
Rust
use super::*;
|
|||
|
|
|
||
|
|
pub(super) async fn maybe_handle(
|
||
|
|
state: &AppState,
|
||
|
|
request_context: &GatewayPublicRequestContext,
|
||
|
|
_request_body: Option<&axum::body::Bytes>,
|
||
|
|
decision: &GatewayControlDecision,
|
||
|
|
) -> Result<Option<Response<Body>>, GatewayError> {
|
||
|
|
if decision.route_family.as_deref() == Some("provider_models_manage")
|
||
|
|
&& decision.route_kind.as_deref() == Some("available_source_models")
|
||
|
|
&& request_context.request_method == http::Method::GET
|
||
|
|
{
|
||
|
|
let Some(provider_id) =
|
||
|
|
admin_provider_available_source_models_path(&request_context.request_path)
|
||
|
|
else {
|
||
|
|
return Ok(Some(
|
||
|
|
(
|
||
|
|
http::StatusCode::NOT_FOUND,
|
||
|
|
Json(json!({ "detail": "Provider 不存在" })),
|
||
|
|
)
|
||
|
|
.into_response(),
|
||
|
|
));
|
||
|
|
};
|
||
|
|
return Ok(Some(
|
||
|
|
match build_admin_provider_available_source_models_payload(state, &provider_id).await {
|
||
|
|
Some(payload) => Json(payload).into_response(),
|
||
|
|
None => (
|
||
|
|
http::StatusCode::NOT_FOUND,
|
||
|
|
Json(json!({ "detail": format!("Provider {provider_id} 不存在") })),
|
||
|
|
)
|
||
|
|
.into_response(),
|
||
|
|
},
|
||
|
|
));
|
||
|
|
}
|
||
|
|
|
||
|
|
Ok(None)
|
||
|
|
}
|