We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, i noticed that the exact same bug / question was already asked in #408 but the code doesn't seem to work (anymore?)
One can define a trait object as state and inject a concrete implementation during runtime
Calling the endpoint returns:
data of type alloc::boxed::Box<dyn crate::Trait> was not found.
alloc::boxed::Box<dyn crate::Trait>
Using the example below the error would be
data of type alloc::boxed::Box<dyn poem-test::api::Database> was not found.
alloc::boxed::Box<dyn poem-test::api::Database>
#[async_trait] pub trait Database: Send + Sync + dyn_clone::DynClone { async fn save(&self, name: String); }
#[oai(path = "/", method = "get")] async fn dummy(&self, Data(implementation): Data<&Box<dyn Database>>) { implementation.save("test".to_string()).await; }
#[derive(Debug, Clone)] pub struct DummyDatabase; #[async_trait] impl Database for DummyDatabase { async fn save(&self, name: String) -> { todo!() } }
let api = OpenApiService(Api, "App", "0.0.1").data(Box::new(DummyDatabase)); let app = Route::new().nest("/", api); // Start it ...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
i noticed that the exact same bug / question was already asked in #408 but the code doesn't seem to work (anymore?)
Expected Behavior
One can define a trait object as state and inject a concrete implementation during runtime
Actual Behavior
Calling the endpoint returns:
Using the example below the error would be
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: