feat(api): add API routes with full state wiring and integration test fixtures
- Add /api routes for agents and proxy resources - Wire all services into ApiState in service/mod.rs - Update route tests with all mock services
This commit is contained in:
@@ -6,6 +6,7 @@ use crate::{connector::agent::AgentConnectorTrait, service::certificate::Certifi
|
||||
|
||||
pub mod agent;
|
||||
pub mod certificate;
|
||||
pub mod error;
|
||||
pub mod proxy;
|
||||
|
||||
pub async fn start_master_server(
|
||||
@@ -51,7 +52,68 @@ pub async fn start_master_server(
|
||||
}
|
||||
});
|
||||
|
||||
let axum_router = crate::routes::get_root_router().await;
|
||||
let api_state = crate::routes::api::ApiState {
|
||||
agent_service: Arc::new(crate::service::agent::AgentServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
)),
|
||||
proxy_service: Arc::new(crate::service::proxy::service::ProxyServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
)),
|
||||
server_block_service: Arc::new(
|
||||
crate::service::proxy::server_block::ServerBlockServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
),
|
||||
),
|
||||
upstream_service: Arc::new(
|
||||
crate::service::proxy::upstream::UpstreamServiceImpl::new(db_connection.clone()),
|
||||
),
|
||||
location_block_service: Arc::new(
|
||||
crate::service::proxy::location_block::LocationBlockServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
),
|
||||
),
|
||||
access_rule_service: Arc::new(
|
||||
crate::service::proxy::access_rule::AccessRuleServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
),
|
||||
),
|
||||
cache_zone_service: Arc::new(
|
||||
crate::service::proxy::cache_zone::CacheZoneServiceImpl::new(db_connection.clone()),
|
||||
),
|
||||
limit_rule_service: Arc::new(
|
||||
crate::service::proxy::limit_rule::LimitRuleServiceImpl::new(db_connection.clone()),
|
||||
),
|
||||
limit_zone_service: Arc::new(
|
||||
crate::service::proxy::limit_zone::LimitZoneServiceImpl::new(db_connection.clone()),
|
||||
),
|
||||
log_setting_service: Arc::new(
|
||||
crate::service::proxy::log_setting::LogSettingServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
),
|
||||
),
|
||||
proxy_setting_service: Arc::new(
|
||||
crate::service::proxy::proxy_setting::ProxySettingServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
),
|
||||
),
|
||||
rewrite_rule_service: Arc::new(
|
||||
crate::service::proxy::rewrite_rule::RewriteRuleServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
),
|
||||
),
|
||||
ssl_certificate_service: Arc::new(
|
||||
crate::service::proxy::ssl_certificate::SslCertificateServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
),
|
||||
),
|
||||
config_inheritance_service: Arc::new(
|
||||
crate::service::proxy::config_inheritance::ConfigInheritanceServiceImpl::new(
|
||||
db_connection.clone(),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
let axum_router = crate::routes::get_root_router(Arc::new(api_state)).await;
|
||||
|
||||
// Start the HTTP server
|
||||
let addr = format!("{}:{}", settings.server.bind_address, settings.server.port)
|
||||
|
||||
Reference in New Issue
Block a user