chore: change to byte slice

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-27 20:16:27 +02:00
parent d3beab5006
commit 541b9b22d2
10 changed files with 829 additions and 746 deletions

View File

@@ -70,37 +70,34 @@ async fn main() -> anyhow::Result<()> {
let cli = Command::parse();
match cli.command {
Some(Commands::Serve { host }) => {
tracing::info!("Starting churn server");
let db = match cli.global.database {
DatabaseType::Sled => Db::new_sled(&cli.global.sled_path),
};
if let Some(Commands::Serve { host }) = cli.command {
tracing::info!("Starting churn server");
let db = match cli.global.database {
DatabaseType::Sled => Db::new_sled(&cli.global.sled_path),
};
let app = Router::new()
.route("/ping", get(ping))
.route("/logs", get(logs))
.nest(
"/agent",
Router::new()
.route("/enroll", post(enroll))
.route("/ping", post(agent_ping))
.route("/events", post(get_tasks))
.route("/lease", post(agent_lease)),
)
.with_state(AppState {
agent: AgentService::new(db.clone()),
leases: LeaseService::default(),
events: EventService::new(db.clone()),
});
let app = Router::new()
.route("/ping", get(ping))
.route("/logs", get(logs))
.nest(
"/agent",
Router::new()
.route("/enroll", post(enroll))
.route("/ping", post(agent_ping))
.route("/events", post(get_tasks))
.route("/lease", post(agent_lease)),
)
.with_state(AppState {
agent: AgentService::new(db.clone()),
leases: LeaseService::new(db.clone()),
events: EventService::new(db.clone()),
});
tracing::info!("churn server listening on {}", host);
axum::Server::bind(&host)
.serve(app.into_make_service())
.await
.unwrap();
}
None => {}
tracing::info!("churn server listening on {}", host);
axum::Server::bind(&host)
.serve(app.into_make_service())
.await
.unwrap();
}
Ok(())
@@ -231,10 +228,10 @@ async fn logs(
.await
.map_err(AppError::Internal)?;
return Ok(Json(ServerMonitorResp {
Ok(Json(ServerMonitorResp {
cursor: Some(cursor),
logs: Vec::new(),
}));
}))
}
}
}