Actix Web
How to migrate a web service that uses Actix Web to Shuttle
Reference
Quickstart
Shuttle has a native integration for Actix Web by default with the shuttle-actix-web
crate.
See the following code comparison below:
How does it work?
The Shuttle runtime exposes a trait, shuttle_runtime::Service
, that services are required to implement before being able to run on Shuttle.
The shuttle-actix-web
crate exposes an aliased Result type (shuttle_axum::ShuttleActixWeb
) which simply wraps your router and implements From<actix_web::ServiceConfig>
which allows use of .into()
on your ServiceConfig
. This integration includes serving the router itself.
Normally one would configure an application with Actix Web using the App struct. However, Shuttle needs to move the users configuration across threads to start the server on our backend, and the App struct is !Send and !Sync.
That means that for Shuttle to support Actix Web, we need to use the ServiceConfig struct. You should be able to configure your application like you normally would, but some steps may be a bit different. If you do you find something that you would expect to be possible not working, please reach out and let us know.
If you want more custom behavior that is not supported by the native Shuttle integration, you can create a struct with your own custom implementation of shuttle_runtime::Service
.