careful-flag-68889
05/13/2023, 6:43 AMrust
use std::path::PathBuf;
use axum::{routing::get, Router};
use axum_extra::routing::SpaRouter;
async fn hello_world() -> &'static str {
"Hello, world!"
}
#[shuttle_runtime::main]
async fn axum(
// Name your static assets folder by passing `folder = <name>` to `StaticFolder`
// If you don't pass a name, it will default to `static`.
#[shuttle_static_folder::StaticFolder(folder = "assets")] static_folder: PathBuf,
) -> shuttle_axum::ShuttleAxum {
let router = Router::new()
.route("/hello", get(hello_world))
.merge(SpaRouter::new("/assets", static_folder).index_file("index.html"));
Ok(router.into())
}
Error:
2023-05-13T08:39:12.639700265Z DEBUG error[E0432]: unresolved import `axum_extra::routing::SpaRouter`
--> src/main.rs:4:5
|
4 | use axum_extra::routing::SpaRouter;
| ^^^^^^^^^^^^^^^^^^^^^---------
| | |
| | help: a similar name exists in the module: `Router`
| no `SpaRouter` in `routing`
2023-05-13T08:39:12.671257094Z DEBUG error[E0599]: no function or associated item named `new` found for struct `StaticFolder` in the current scope
--> src/main.rs:10:1
|
10 | #[shuttle_runtime::main]
| ^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `StaticFolder<'_>`
|
= help: items from traits can only be used if the trait is in scope
= note: this error originates in the attribute macro `shuttle_runtime::main` (in Nightly builds, run with -Z macro-backtrace for more info)
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
1 | use shuttle_service::ResourceBuilder;
|
Dependencies:
toml
[dependencies]
shuttle-runtime = "0.14.0"
axum = "0.6.17"
shuttle-axum = "0.14.0"
tokio = "1.28.0"
shuttle-static-folder = "0.16.0"
axum-extra = "0.7.4"
Rust version: rust 1.71.0-nightly
What is causing this?gentle-agency-53651
05/13/2023, 7:35 AMcareful-flag-68889
05/13/2023, 7:47 AMno function or associated item named `new` found for struct `StaticFolder` in the current scope
--> src/main.rs:10:1
|
10 | #[shuttle_runtime::main]
| ^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `StaticFolder<'_>`
|
= help: items from traits can only be used if the trait is in scope
= note: this error originates in the attribute macro `shuttle_runtime::main` (in Nightly builds, run with -Z macro-backtrace for more info)
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
1 | use shuttle_service::ResourceBuilder;
|
careful-flag-68889
05/13/2023, 7:47 AMagreeable-painting-48846
05/13/2023, 9:10 AMcareful-flag-68889
05/13/2023, 9:11 AMcargo-shuttle 0.16.0
(cargo shuttle --version
)careful-flag-68889
05/13/2023, 9:11 AMagreeable-painting-48846
05/13/2023, 9:12 AMcareful-flag-68889
05/13/2023, 9:12 AMtoml
[dependencies]
shuttle-runtime = "0.14.0"
axum = "0.6.17"
shuttle-axum = "0.14.0"
tokio = "1.28.0"
shuttle-static-folder = "0.16.0"
axum-extra = "0.7.4"
careful-flag-68889
05/13/2023, 9:13 AMagreeable-painting-48846
05/13/2023, 9:14 AMcareful-flag-68889
05/13/2023, 9:14 AMagreeable-painting-48846
05/13/2023, 9:15 AMcareful-flag-68889
05/13/2023, 9:16 AMcareful-flag-68889
05/13/2023, 9:16 AMagreeable-painting-48846
05/13/2023, 9:17 AMcareful-flag-68889
05/13/2023, 9:17 AMcareful-flag-68889
05/13/2023, 9:18 AMcargo shuttle init
careful-flag-68889
05/13/2023, 9:20 AMcareful-flag-68889
05/13/2023, 9:22 AMServeDir
here? Would I just remove the static_folder
macro and argument?careful-flag-68889
05/13/2023, 9:25 AMRouter.merge
doesn't work with itagreeable-painting-48846
05/13/2023, 9:27 AM