32 lines
763 B
Rust
32 lines
763 B
Rust
use askama::Template;
|
|
use askama_axum::IntoResponse;
|
|
use axum::{
|
|
extract::{Path, State},
|
|
response::Redirect,
|
|
};
|
|
|
|
use crate::{http::error::AppError, node::stack::operation, AppState};
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "stack/delete-one.html")]
|
|
struct ConfirmDeleteTemplate {
|
|
stack_name: String,
|
|
}
|
|
|
|
pub(super) async fn confirm_deletion_page(Path(stack_name): Path<String>) -> impl IntoResponse {
|
|
ConfirmDeleteTemplate { stack_name }
|
|
}
|
|
|
|
pub(super) async fn delete_stack(
|
|
Path(stack_name): Path<String>,
|
|
State(state): State<AppState>,
|
|
) -> Result<Redirect, AppError> {
|
|
operation::remove(
|
|
&state.stack_dir,
|
|
&state.arion_bin,
|
|
state.repository,
|
|
&stack_name,
|
|
)
|
|
.await?;
|
|
Ok(Redirect::to("/"))
|
|
}
|