You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to share routes between a lambda with a normal axum server so that I can run a local server for development and integration testing and deploy as a lambda (which is proxied via API Gateway). This means the router needs to work with both axum::body::Body and lambda_http::Body.
So I defined a generic function that declares the routes with this signature:
pubfnservice<B>() -> Router<(),B>whereB:HttpBody + Send + 'static,
<BasHttpBody>::Data:Send,
<BasHttpBody>::Error:Send + Sync + std::error::Error + 'static
{Router::new()// all the service routes}
Which works fine for a normal axum server using axum::body::Body (note I cannot remove the std::error::Error trait bound as it is required for axum routing).
However when I invoke the service() function from the code that calls lambda_http::run to set up the routes I get this compiler error:
|
66 | let v1 = server::Server::service();
| ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn std::error::Error + Send + Sync + 'static)`
= help: the following other types implement trait `std::error::Error`:
Box<(dyn sqlx_core::error::DatabaseError + 'static)>
Box<T>
= note: required for `Box<(dyn std::error::Error + Send + Sync + 'static)>` to implement `std::error::Error`
note: required by a bound in `sos_platform::server::Server::service`
--> /Users/muji/git/sos/platform/src/server.rs:76:47
|
76 | <B as HttpBody>::Error: Send + Sync + std::error::Error + 'static
| ^^^^^^^^^^^^^^^^^ required by this bound in `Server::service`
For more information about this error, try `rustc --explain E0277`.
Which appears to be because the HttpBody implementation in lambda_events uses an associated type Error which is defined as:
This discussion was converted from issue #685 on August 24, 2023 15:25.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I am trying to share routes between a lambda with a normal axum server so that I can run a local server for development and integration testing and deploy as a lambda (which is proxied via API Gateway). This means the router needs to work with both
axum::body::Body
andlambda_http::Body
.So I defined a generic function that declares the routes with this signature:
Which works fine for a normal axum server using
axum::body::Body
(note I cannot remove thestd::error::Error
trait bound as it is required for axum routing).However when I invoke the
service()
function from the code that callslambda_http::run
to set up the routes I get this compiler error:Which appears to be because the
HttpBody
implementation inlambda_events
uses an associated typeError
which is defined as:I think to fix this
HttpBody::Error
would need to be a concrete type rather then a type alias so it implementsSized
. Is that correct?At the moment I can workaround this by duplicating my routes in the lambda but that's very far from ideal.
Beta Was this translation helpful? Give feedback.
All reactions