rwf2 / Rocket

A web framework for Rust.
https://rocket.rs
Other
24.4k stars 1.56k forks source link

Project Structure #555

Closed ghost closed 6 years ago

ghost commented 6 years ago

Questions

I am using Rocket 0.3.6,In my project, I want organize my files like this: ----pro

I want to organize all routes in a mod, but when I finished it in route/mod.rs,

![feature(plugin)]

![plugin(rocket_codegen)]

extern crate rocket; extern crate rocket_codegen;

[get("/world")]

fn world() -> &'static str { "Hello,World" } something wrong!

image

does the route have to place in src/main.rs? how to solve this? thanks.

SergioBenitez commented 6 years ago

You need to place

#![feature(plugin)]
#![plugin(rocket_codegen)]

at the crate root. This is usually src/main.rs. Note that this is true for Rust in general: crate attributes need to be at the crate root.

ghost commented 6 years ago

Thanks. problem has been solved @SergioBenitez

spacekookie commented 6 years ago

@SergioBenitez I'd actually be curious what your opinions are of more rigidly enforcing a project structure (like Django or ember.js)