summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs53
1 files changed, 9 insertions, 44 deletions
diff --git a/src/lib.rs b/src/lib.rs
index dc0efe7..6a64876 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,50 +1,15 @@
-use serde::{Deserialize, Serialize};
-use service::ServiceHandles;
-
-pub use crate::error::{Error, Result};
+pub use crate::{
+ error::{Error, Result},
+ state::AppState,
+ status::Status,
+};
pub mod api;
pub mod error;
pub mod service;
-pub mod sse;
-
-pub fn router() -> axum::Router<ServiceHandles> {
- axum::Router::new()
- .nest("/api", api::router())
- .nest("/sse", sse::router())
-}
-
-#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
-#[serde(rename_all = "lowercase", tag = "status", content = "output")]
-pub enum Status {
- Ok,
- Error(Option<String>),
-}
-
-impl Default for Status {
- fn default() -> Self {
- Status::Error(Some("Unknown".to_string()))
- }
-}
-
-impl Status {
- pub fn update(&mut self, status: Status) -> bool {
- let modif = *self != status;
- if modif {
- *self = status;
- }
- modif
- }
-}
-
-impl<T: std::error::Error> From<T> for Status {
- fn from(value: T) -> Self {
- Status::Error(Some(value.to_string()))
- }
-}
+pub mod state;
+pub mod status;
-impl axum::response::IntoResponse for Status {
- fn into_response(self) -> axum::response::Response {
- axum::Json(self).into_response()
- }
+pub fn router() -> axum::Router<AppState> {
+ axum::Router::new().nest("/api/v1", api::router())
}