diff --git a/examples/minimal/src/app.rs b/examples/minimal/src/app.rs index a499a2b6..c364cbc2 100644 --- a/examples/minimal/src/app.rs +++ b/examples/minimal/src/app.rs @@ -7,7 +7,7 @@ use roadster::service::registry::ServiceRegistry; use roadster::service::worker::sidekiq::app_worker::AppWorker; use roadster::service::worker::sidekiq::service::SidekiqWorkerService; -use crate::app_state::AppState; +use crate::app_state::CustomAppContext; use crate::cli::AppCli; use crate::controller; use crate::worker::example::ExampleWorker; @@ -19,7 +19,7 @@ pub struct App; #[async_trait] impl RoadsterApp for App { - type State = AppState; + type State = CustomAppContext; type Cli = AppCli; type M = Migrator; diff --git a/examples/minimal/src/app_state.rs b/examples/minimal/src/app_state.rs index e65fb25e..185e7a28 100644 --- a/examples/minimal/src/app_state.rs +++ b/examples/minimal/src/app_state.rs @@ -1,5 +1,5 @@ -// We need to use the disallowed `roadster::app_context::AppContext` type in this module in order -// to implement the required traits used to convert it to/from `AppState`. -#![allow(clippy::disallowed_types)] +use roadster::app_context::AppContext; -pub type AppState = (); +pub type CustomAppContext = (); + +pub type AppState = AppContext; diff --git a/examples/minimal/src/cli/mod.rs b/examples/minimal/src/cli/mod.rs index efbc8d4d..103c4a76 100644 --- a/examples/minimal/src/cli/mod.rs +++ b/examples/minimal/src/cli/mod.rs @@ -5,7 +5,7 @@ use roadster::app_context::AppContext; use roadster::cli::RunCommand; use crate::app::App; -use crate::app_state::AppState; +use crate::app_state::CustomAppContext; /// Minimal Example: Commands specific to managing the `minimal` app are provided in the CLI /// as well. Subcommands not listed under the `roadster` subcommand are specific to `minimal`. @@ -23,7 +23,7 @@ impl RunCommand for AppCli { &self, app: &App, cli: &AppCli, - context: &AppContext, + context: &AppContext, ) -> anyhow::Result { if let Some(command) = self.command.as_ref() { command.run(app, cli, context).await @@ -45,7 +45,7 @@ impl RunCommand for AppCommand { &self, _app: &App, _cli: &AppCli, - _context: &AppContext, + _context: &AppContext, ) -> anyhow::Result { Ok(false) } diff --git a/examples/minimal/src/controller/example.rs b/examples/minimal/src/controller/example.rs index cec0ef31..fb036d6f 100644 --- a/examples/minimal/src/controller/example.rs +++ b/examples/minimal/src/controller/example.rs @@ -5,7 +5,6 @@ use aide::axum::ApiRouter; use aide::transform::TransformOperation; use axum::extract::State; use axum::Json; -use roadster::app_context::AppContext; use roadster::controller::build_path; use roadster::service::worker::sidekiq::app_worker::AppWorker; use roadster::view::app_error::AppError; @@ -16,7 +15,7 @@ use tracing::instrument; const BASE: &str = "/example"; const TAG: &str = "Example"; -pub fn routes(parent: &str) -> ApiRouter> { +pub fn routes(parent: &str) -> ApiRouter { let root = build_path(parent, BASE); ApiRouter::new().api_route(&root, get_with(example_get, example_get_docs)) @@ -27,9 +26,7 @@ pub fn routes(parent: &str) -> ApiRouter> { pub struct ExampleResponse {} #[instrument(skip_all)] -async fn example_get( - State(state): State>, -) -> Result, AppError> { +async fn example_get(State(state): State) -> Result, AppError> { ExampleWorker::enqueue(&state, "Example".to_string()).await?; Ok(Json(ExampleResponse {})) } diff --git a/examples/minimal/src/controller/mod.rs b/examples/minimal/src/controller/mod.rs index da3866f0..a790f6e6 100644 --- a/examples/minimal/src/controller/mod.rs +++ b/examples/minimal/src/controller/mod.rs @@ -1,9 +1,8 @@ use crate::app_state::AppState; use aide::axum::ApiRouter; -use roadster::app_context::AppContext; pub mod example; -pub fn routes(parent: &str) -> ApiRouter> { +pub fn routes(parent: &str) -> ApiRouter { ApiRouter::new().merge(example::routes(parent)) } diff --git a/examples/minimal/src/worker/example.rs b/examples/minimal/src/worker/example.rs index af7bc615..efe4b3fc 100644 --- a/examples/minimal/src/worker/example.rs +++ b/examples/minimal/src/worker/example.rs @@ -1,7 +1,6 @@ use crate::app::App; use crate::app_state::AppState; use async_trait::async_trait; -use roadster::app_context::AppContext; use roadster::service::worker::sidekiq::app_worker::AppWorker; use sidekiq::Worker; use tracing::{info, instrument}; @@ -19,7 +18,7 @@ impl Worker for ExampleWorker { #[async_trait] impl AppWorker for ExampleWorker { - fn build(_context: &AppContext) -> Self { + fn build(_context: &AppState) -> Self { Self {} } }