Our great sponsors
-
paperclip
Discontinued WIP OpenAPI tooling for Rust. [Moved to: https://github.com/paperclip-rs/paperclip] (by wafflespeanut)
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Not the most elegant of solutions, but it worked. Now seems like a good time, by the way, to take away a point for "MUST have great documentation". While the docs for using actix-web as intended were good, I'm far off the beaten path at this point and will only go further. I didn't find any docs at all to help me with this nor later code, and instead spent a lot of time digging through source code and deciphering cryptic compiler errors.
I got actix-web + Paperclip working with AWS SAM. Development was time consuming, troubleshooting was frustrating, and the end result was fragile and ugly. In future blog posts I will be experimenting with other solutions and hoping for a much nicer result. I'll only return to the actix-web approach if other methods are somehow even worse.
There is probably some standard way to get around this sort of stuff, but I couldn't figure it out, certainly not with messages as cryptic as the ones I was getting. So I turned to a crate I found called warp_lambda. That's right, I found a crate that allows you to run warp on AWS Lambda. As a reminder, rweb, the most promising option from a functional standpoint, is based on warp.
The code works... but barely. If you want to see the end result, I have put it up in a GitHub Repository where I also intend to add future experiments in other frameworks. If you haven't gathered as much from all of the text above, this code is fragile, slow, and in no way recommended for production. But if you're more experienced (or dedicated) than I am and want to try your hand at making it better, go for it!
This crate has an implementation for the Handler trait which I used to model my own Handler trait for an actix-web Service. Using my own struct which implemented that trait suddenly made the "this is not Send" error messages simple enough to decipher. I was able to get the thing to actually compile, but it required using a few unwrap()s on errors which were not Send. I could probably go back and figure out how to wrap or map those errors to something simpler to make my implementation less fragile, but I was already annoyed enough at this implementation that I was headed toward rweb anyway.
Cover image created by me using Ferris the Crab, the Rust logo, and the FastAPI logo.