Can anyone help me? Here is my code.
Also when I nest the directory inside a lib directory it then tell me src/routes/mod.rs doesnt exist
Thank you!
File structure
.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── src
│ ├── lib.rs
│ ├── main.rs
│ └── routes
│ ├── echo.rs
│ └── mod.rs
├── static
│ └── abruzzo.png
└── tests
└── basic_test.rs
main.rs
mod lib;
fn main() {
lib::rocket_builder().launch();
}
lib.rs
#![feature(proc_macro_hygiene, decl_macro)]
#![allow(unused_attributes)]
#[macro_use] use rocket::*;
use rocket_contrib::helmet::SpaceHelmet;
mod routes;
pub fn rocket_builder() -> rocket::Rocket {
rocket::ignite().attach(SpaceHelmet::default())
.mount("/", routes![routes::echo::echo_fn])
}
echo.rs
use rocket::*;
#[get("/echo/<echo>")]
pub fn echo_fn(echo: String) -> String {
echo
}
mod.rs
pub mod echo;
Error:
error[E0583]: file not found for module `routes`
--> src\lib.rs:8:1
|
8 | mod routes;
| ^^^^^^^^^^^
|
= help: to create the module `routes`, create file "src\lib\routes.rs" or "src\lib\routes\mod.rs"
error[E0433]: failed to resolve: could not find `echo` in `routes`
--> src\lib.rs:12:33
|
12 | .mount("/", routes![routes::echo::echo_fn])
| ^^^^ could not find `echo` in `routes`
Some errors have detailed explanations: E0433, E0583.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `rocket-mongo` due to 2 previous errors