use axum::{ extract::{Path, State}, http::StatusCode, Json, }; use crate::{ model::{ProviderEndpoint, ProviderEndpointInput}, Result, }; use super::ControlService; pub async fn list(State(service): State) -> Result>> { Ok(Json(service.providers().await?)) } pub async fn create( State(service): State, Json(input): Json, ) -> Result<(StatusCode, Json)> { Ok(( StatusCode::CREATED, Json(service.create_provider(&input).await?), )) } pub async fn update( State(service): State, Path(provider_id): Path, Json(input): Json, ) -> Result> { Ok(Json(service.update_provider(provider_id, &input).await?)) } pub async fn remove( State(service): State, Path(provider_id): Path, ) -> Result { service.delete_provider(provider_id).await?; Ok(StatusCode::NO_CONTENT) }