This commit is contained in:
2025-04-20 09:42:22 +02:00
parent 616d3247b6
commit ec6da0b4e0
9 changed files with 125 additions and 56 deletions

View File

@@ -9,7 +9,7 @@ use tokio::sync::RwLock;
use serde_json::json;
use log::{error, info};
use utoipa::OpenApi;
use utoipa_swagger_ui::SwaggerUi;
use utoipa_redoc::{Redoc, Servable};
use crate::ACLDB;
use crate::rpc::{RpcInterface, RpcRequest, RpcResponse, AclUpdateParams, AclRemoveParams, AclDelParams, SetParams, DelParams, GetParams, PrefixParams};
@@ -164,7 +164,7 @@ impl Server {
self.register_handlers();
info!("Starting ACLDB server on {}:{}", self.config.host, self.config.port);
info!("Swagger UI available at: http://{}:{}/swagger-ui/", self.config.host, self.config.port);
info!("API documentation available at: http://{}:{}/redoc", self.config.host, self.config.port);
// Start the HTTP server
HttpServer::new(move || {
@@ -180,8 +180,7 @@ impl Server {
.route("/rpc", web::post().to(handle_rpc))
.route("/health", web::get().to(health_check))
.service(
SwaggerUi::new("/swagger-ui/{_:.*}")
.url("/api-docs/openapi.json", ApiDoc::openapi())
Redoc::with_url("/redoc", serde_json::to_value(ApiDoc::openapi()).unwrap())
)
})
.bind(format!("{0}:{1}", self.config.host, self.config.port))?
@@ -311,7 +310,7 @@ async fn handle_rpc(
/// Process an RPC request
async fn process_request(
request: &RpcRequest,
rpc_interface: &Arc<RpcInterface>,
_rpc_interface: &Arc<RpcInterface>,
acldb_factory: &Arc<ACLDBFactory>
) -> RpcResponse {
match request.method.as_str() {