staxman-old/src/route/stack/delete.rs

33 lines
749 B
Rust

use askama::Template;
use askama_axum::IntoResponse;
use axum::{
extract::{Path, State},
response::Redirect,
};
use crate::{http::error::AppError, node::stack::remove, 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> {
remove(
&state.stack_dir,
&state.arion_bin,
state.repository,
&stack_name,
)
.await?;
Ok(Redirect::to("/"))
}