This repository has been archived on 2024-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
staxman-old/src/route/stack/delete.rs

33 lines
763 B
Rust
Raw Normal View History

2023-11-25 12:24:06 +01:00
use askama::Template;
use askama_axum::IntoResponse;
use axum::{
extract::{Path, State},
response::Redirect,
};
2023-11-25 14:05:21 +01:00
use crate::{http::error::AppError, node::stack::operation, AppState};
2023-11-25 12:24:06 +01:00
#[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> {
2023-11-25 14:05:21 +01:00
operation::remove(
2023-11-25 12:24:06 +01:00
&state.stack_dir,
&state.arion_bin,
state.repository,
&stack_name,
)
.await?;
Ok(Redirect::to("/"))
}