Replies: 3 comments 11 replies
-
Why? What enforces this restriction? The code you wrote seems like it could just use a routing. |
Beta Was this translation helpful? Give feedback.
-
Having researched this some more I think the only way to do this is to strip a prefix from the request URI before routing begins. This is what I want to achieve:
Please bear in mind this entire problem is because API Gateway made the dubious decision to include the I got the version prefix working thanks to the tip from @davidpdrsn on using In API Gateway create a base path mapping for the custom domain name, let's call the stage ( We would invoke this with:
Which when the API Gateway transforms it and invokes the lambda it will be exposed to axum as:
So I created middleware which rewrites the request URI but this doesn't work when I invoke via lambda (thanks to Is there a mechanism in the |
Beta Was this translation helpful? Give feedback.
-
Now the final part of the puzzle is sharing the I have this function definition: pub fn service<B>() -> Router<(), B> where
B: HttpBody + Send + 'static,
<B as HttpBody>::Data: Send,
<B as HttpBody>::Error: Send + Sync + std::error::Error + 'static
{
Router::new() // all the service routes
} Which works fine for the normal axum server. However, when I try to invoke the function from the lambda I get this error:
I can't remove the
Any ideas how to fix this? Thanks 🙏 |
Beta Was this translation helpful? Give feedback.
-
I have a service that I would like to work on AWS lambda via API Gateway and as a standalone server so I can choose between serverless and a managed server.
I have the API working well as a standalone server and I can get it working via API Gateway/Lambda with a crude proxy function. The main restrictions are that the API Gateway Proxy integration requires a single wildcard route and use of
any()
method.So my code for the lambda deployment ends up looking something like this (abbreviated for brevity):
So whilst this works it is horrible. Is there a better way to achieve this whereby I could:
Any suggestions welcome, thanks 🙏
Beta Was this translation helpful? Give feedback.
All reactions