-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
39 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
pub mod authentication; | ||
pub mod cluster_router; | ||
pub mod state; | ||
use authentication::auth; | ||
use axum::{middleware, Router}; | ||
use cluster_router::get_cluster_router; | ||
use rucat_common::error::Result; | ||
use state::{data_store::DataStore, AppState}; | ||
use surrealdb::{engine::local::Mem, Surreal}; | ||
use tower_http::trace::TraceLayer; | ||
|
||
pub(crate) mod authentication; | ||
pub(crate) mod cluster_router; | ||
pub(crate) mod state; | ||
|
||
/// This is the only entry for users to get the rucat server. | ||
pub async fn get_server() -> Result<Router> { | ||
// setup tracing | ||
tracing_subscriber::fmt::init(); | ||
|
||
let db = Surreal::new::<Mem>(()).await?; | ||
db.use_ns("test").use_db("test").await?; | ||
|
||
let app_state = AppState::new(DataStore::connect_embedded_db(db)); | ||
|
||
Ok(Router::new() | ||
.nest("/cluster", get_cluster_router()) | ||
.layer(middleware::from_fn(auth)) | ||
.layer(TraceLayer::new_for_http()) | ||
.with_state(app_state)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters