-
Notifications
You must be signed in to change notification settings - Fork 19
Support for Rocket 0.5 #3
Comments
That would be awesome |
I would be very interested in giving a helping hand on this one. |
I started working on this in a fork here. So far this:
Right now I'm stuck on a lifetime issue. The |
Well I sort of fixed it by adding a bunch of Arcs, but I had to remove some functionality around dynamically resetting the base path of the mounted routes for each request. I'm hoping there's a better way to achieve that anyway but I'll need to gather more information first. Next step is trying to get the tests to pass. Currently none of them compile because:
|
Nice work Dylan, I saw Arc is used inside Rocket itself and in other projects that are using Tokio so that might be the correct approach. I have addressed the async tests issues here. The tests appear to compile now, but there is one remaining error.
|
Thanks David! I switched to Rust stable in my fork since that's supported on Rocket master and because the latest nightly was causing some build errors. I then managed to fix all the compilation issues 🎉! Tests can build and run now, though 7 are failing. I think the next step is to see if there are any failing that aren't related to the feature I removed and fix those. Then we can see about re-implementing the base-path feature with the new code. Maybe we can strip the base path out of the request at call time instead of changing the registration of the paths? Not totally sure. @GREsau would you be able to give us some insight to the purpose of If we do need to go the re-mount route we might have to use some internal mutability to make it work. Some sort of Cell maybe? |
Another update, all the unit tests now pass!! I did change all the path tests to not use a macro anymore for my own sanity with debugging, but I believe they're all effectively the same. The implementation to get the There is also now an API Gateway V2 request format which the lamedh crates support. I believe I've fished out the correct pieces needed in order to make stage/base path replacement work correctly though I'd love a second set of eyes on that as well. I think now that all the tests pass the next step is to actually attempt to use this thing and fix any issues that come up. If all goes well this will be my last update on this issue for a while, I'm not planning on making a PR back to this upstream repo until Rocket 0.5 is actually released. |
I actually started writing a blog post on this last year but never got around to finishing it unfortunately - but your guess pretty much nails it. You can configure your API Gateway to use:
The intention of Otherwise, you would need your application to know what base path it will be running under and ensure you mount your routes at that base path (this is the behaviour with I would much prefer it if there were a way to tell Rocket that part of the request's URL is a "base path" which it should ignore for routing purposes, similar to Also, determining the base path from the API Gateway request object is a bit of a hassle (as you can probably guess from the mess in |
Hey maintainers,
For reference, I’m also using
And the fork for Rocket 0.5 like so.
I’ll try and fix it myself (using the handy explain function!), but I’m really new to Rust. Again my sincere apologies for this comment but you might be able to educate me on this, thanks for your time. |
@DragonStuff Rust is very particular about the way you use Git dependencies. If two places depend on the same Git-based crate they have to be declared exactly the same way. In this case, my fork declares Rocket like
so you probably need to use exactly that in your Cargo.toml. You can also check out my experiments repo where I have a few branches using this that all compiled and ran last I checked. The branch called rocket-0.5-CDK is probably the most up to date. |
I just tried @dbanty's fork with the latest 0.5.0-dev and got this error.
I did not quite work out what the issue was though :( I ran a modified version of https://github.com/GREsau/example-rocket-lamb-api with the following dependencies in Cargo.toml
|
The |
I've forked this, and I think I've managed to fix the few things that broke.
No more compilation errors from |
I just submitted a pull request with the fixes. |
In case someone needs the fix right away, here is my fork. |
Merged! Thanks @mwnDK1402! |
I'm using Rocket 0.5 with @dbanty's fork, but I haven't tested this on older versions. It says here that you can specify thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Config(Error { tag: Tag(Global, 3), profile: Some(Profile(Uncased { string: "global" })), metadata: Some(Metadata { name: "`ROCKET_` environment variable(s)", source: None, provide_location: Some(Location { file: "/root/.cargo/git/checkouts/rocket-8bf16d9ca7e90bdc/0d53e23/core/lib/src/config/config.rs", line: 213, col: 14 }), interpolater: }), path: ["cli_colors"], kind: InvalidValue(Str("off"), "true or false"), prev: None })', rocket-lamb/src/handler.rs:103:49 |
And when I actually set it to
|
FYI looks like there is a fresh alternative to this crate in lambda_web. but this crate does have a cooler sounding name :) |
That's a really cool crate! Great that someone is moving the serverless tooling forward! |
I know that Rocket 0.5 is still in development but I was wondering if you had any thoughts about how to support it? It brings with it async support via Tokio 1.0 which (as far as I know) will be incompatible with the current lambda_runtime crate. In other projects I've been using netlify_lambda which is a fork of the official project that's been updated for Tokio 1.0, so maybe that's a good option?
I don't know what else is changing with Rocket 0.5 that might disrupt things, but I'm happy to take a swing at making it work. I mostly just wanted to check in to see if you have plans to / a strategy for supporting it.
The text was updated successfully, but these errors were encountered: