Crates.io | axum-containerssh |
lib.rs | axum-containerssh |
version | 0.5.0-crt1 |
source | src |
created_at | 2024-01-25 17:27:49.084548 |
updated_at | 2024-02-15 15:27:16.876995 |
description | This OpenAPI document describes the API endpoints that are required for implementing an authentication and configuration server for ContainerSSH. (See https://github.com/containerssh/libcontainerssh for details.) |
homepage | |
repository | |
max_upload_size | |
id | 1114122 |
size | 1,748,677 |
This OpenAPI document describes the API endpoints that are required for implementing an authentication and configuration server for ContainerSSH. (See https://github.com/containerssh/libcontainerssh for details.)
This server was generated by the [openapi-generator] (https://openapi-generator.tech) project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.
To see how to make this your own, look here: README
API version: 0.5.0
Build date: 2024-01-25T16:54:36.302357845Z[Etc/UTC]
This autogenerated project defines an API crate axum-containerssh
which contains:
Api
trait defining the API in Rust.Api
method for each operation.
The generated library has a few optional features that can be activated through Cargo.
server
conversions
See https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section for how to use features in your Cargo.toml
.
struct ServerImpl {
// database: sea_orm::DbConn,
}
#[allow(unused_variables)]
#[async_trait]
impl axum-containerssh::Api for ServerImpl {
// API implementation goes here
}
pub async fn start_server(addr: &str) {
// initialize tracing
tracing_subscriber::fmt::init();
// Init Axum router
let app = axum-containerssh::server::new(Arc::new(ServerImpl));
// Add layers to the router
let app = app.layer(...);
// Run the server with graceful shutdown
let listener = TcpListener::bind(addr).await.unwrap();
axum::serve(listener, app)
.with_graceful_shutdown(shutdown_signal())
.await
.unwrap();
}
async fn shutdown_signal() {
let ctrl_c = async {
signal::ctrl_c()
.await
.expect("failed to install Ctrl+C handler");
};
#[cfg(unix)]
let terminate = async {
signal::unix::signal(signal::unix::SignalKind::terminate())
.expect("failed to install signal handler")
.recv()
.await;
};
#[cfg(not(unix))]
let terminate = std::future::pending::<()>();
tokio::select! {
_ = ctrl_c => {},
_ = terminate => {},
}
}