This plugin allows services to get the path to a static folder at runtime.
Add shuttle-static-folder
to the dependencies for your service.
This resource will be provided by adding the shuttle_static_folder::StaticFolder
attribute to main
.
It returns a PathBuf
which holds the location of the static folder.
The folder obtained will be consistent between deployments, but will not be in the same folder as the executable. This has implications when using some frameworks such as Rocket because it becomes necessary to override the default location when using Rocket's dynamic templates or static file serving features.
shuttle-static-folder
| Framework | Link | |-----------|-------------------------------------------------------------------------------------------------------------| | Axum | axum websocket example | | Rocket | rocket dynamic template example |
``` rust
async fn app( #[shuttlestaticfolder::StaticFolder] staticfolder: PathBuf, ) -> _ { ... } ```
| Parameter | Type | Default | Description |
|-----------|------|----------|--------------------------------------------------------------------|
| folder | str | static
| The relative path, from the crate root, to the directory containing static files to deploy |
Since this plugin defaults to the static
folder, the arguments can be used to use the public
folder instead.
``` rust
async fn app( #[shuttlestaticfolder::StaticFolder(folder = "public")] publicfolder: PathBuf, ) -> _ { ... } ```