pinakes-server: update remaining route imports and handlers
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I67206fd813d514f8903041eea0a4cd266a6a6964
This commit is contained in:
parent
2b2c1830a1
commit
eb6c0a3577
20 changed files with 169 additions and 87 deletions
|
|
@ -3,7 +3,11 @@ use axum::{
|
|||
extract::{Path, State},
|
||||
};
|
||||
|
||||
use crate::{dto::*, error::ApiError, state::AppState};
|
||||
use crate::{
|
||||
dto::{InstallPluginRequest, PluginResponse, TogglePluginRequest},
|
||||
error::ApiError,
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
/// List all installed plugins
|
||||
pub async fn list_plugins(
|
||||
|
|
@ -37,8 +41,7 @@ pub async fn get_plugin(
|
|||
|
||||
let plugin = plugin_manager.get_plugin(&id).await.ok_or_else(|| {
|
||||
ApiError(pinakes_core::error::PinakesError::NotFound(format!(
|
||||
"Plugin not found: {}",
|
||||
id
|
||||
"Plugin not found: {id}"
|
||||
)))
|
||||
})?;
|
||||
|
||||
|
|
@ -63,7 +66,7 @@ pub async fn install_plugin(
|
|||
.await
|
||||
.map_err(|e| {
|
||||
ApiError(pinakes_core::error::PinakesError::InvalidOperation(
|
||||
format!("Failed to install plugin: {}", e),
|
||||
format!("Failed to install plugin: {e}"),
|
||||
))
|
||||
})?;
|
||||
|
||||
|
|
@ -91,7 +94,7 @@ pub async fn uninstall_plugin(
|
|||
|
||||
plugin_manager.uninstall_plugin(&id).await.map_err(|e| {
|
||||
ApiError(pinakes_core::error::PinakesError::InvalidOperation(
|
||||
format!("Failed to uninstall plugin: {}", e),
|
||||
format!("Failed to uninstall plugin: {e}"),
|
||||
))
|
||||
})?;
|
||||
|
||||
|
|
@ -113,13 +116,13 @@ pub async fn toggle_plugin(
|
|||
if req.enabled {
|
||||
plugin_manager.enable_plugin(&id).await.map_err(|e| {
|
||||
ApiError(pinakes_core::error::PinakesError::InvalidOperation(
|
||||
format!("Failed to enable plugin: {}", e),
|
||||
format!("Failed to enable plugin: {e}"),
|
||||
))
|
||||
})?;
|
||||
} else {
|
||||
plugin_manager.disable_plugin(&id).await.map_err(|e| {
|
||||
ApiError(pinakes_core::error::PinakesError::InvalidOperation(
|
||||
format!("Failed to disable plugin: {}", e),
|
||||
format!("Failed to disable plugin: {e}"),
|
||||
))
|
||||
})?;
|
||||
}
|
||||
|
|
@ -143,7 +146,7 @@ pub async fn reload_plugin(
|
|||
|
||||
plugin_manager.reload_plugin(&id).await.map_err(|e| {
|
||||
ApiError(pinakes_core::error::PinakesError::InvalidOperation(
|
||||
format!("Failed to reload plugin: {}", e),
|
||||
format!("Failed to reload plugin: {e}"),
|
||||
))
|
||||
})?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue