diff --git a/src/gen/templates/controller/api/controller.t b/src/gen/templates/controller/api/controller.t index 1982f1426..7136bb870 100644 --- a/src/gen/templates/controller/api/controller.t +++ b/src/gen/templates/controller/api/controller.t @@ -32,7 +32,7 @@ pub async fn {{action}}(State(_ctx): State) -> Result { pub fn routes() -> Routes { Routes::new() - .prefix("{{file_name | plural}}/") + .prefix("api/{{file_name | plural}}/") .add("/", get(index)) {%- for action in actions %} .add("{{action}}", get({{action}})) diff --git a/src/gen/templates/scaffold/api/controller.t b/src/gen/templates/scaffold/api/controller.t index 382eb6a29..d81c0bf44 100644 --- a/src/gen/templates/scaffold/api/controller.t +++ b/src/gen/templates/scaffold/api/controller.t @@ -81,7 +81,7 @@ pub async fn get_one(Path(id): Path, State(ctx): State) -> Resu pub fn routes() -> Routes { Routes::new() - .prefix("{{file_name | plural}}/") + .prefix("api/{{file_name | plural}}/") .add("/", get(list)) .add("/", post(add)) .add(":id", get(get_one)) diff --git a/starters/lightweight-service/src/app.rs b/starters/lightweight-service/src/app.rs index 2e7fff178..4796bc1fc 100644 --- a/starters/lightweight-service/src/app.rs +++ b/starters/lightweight-service/src/app.rs @@ -35,9 +35,7 @@ impl Hooks for App { } fn routes(_ctx: &AppContext) -> AppRoutes { - AppRoutes::empty() - .prefix("/api") - .add_route(controllers::home::routes()) + AppRoutes::empty().add_route(controllers::home::routes()) } async fn connect_workers(_ctx: &AppContext, _queue: &Queue) -> Result<()> { diff --git a/starters/lightweight-service/src/controllers/home.rs b/starters/lightweight-service/src/controllers/home.rs index d3330ebb5..0d6430f60 100644 --- a/starters/lightweight-service/src/controllers/home.rs +++ b/starters/lightweight-service/src/controllers/home.rs @@ -9,5 +9,5 @@ async fn current() -> Result { } pub fn routes() -> Routes { - Routes::new().add("/", get(current)) + Routes::new().prefix("/api").add("/", get(current)) } diff --git a/starters/rest-api/src/app.rs b/starters/rest-api/src/app.rs index c2f802bcc..8b191321b 100644 --- a/starters/rest-api/src/app.rs +++ b/starters/rest-api/src/app.rs @@ -44,7 +44,6 @@ impl Hooks for App { fn routes(_ctx: &AppContext) -> AppRoutes { AppRoutes::with_default_routes() - .prefix("/api") .add_route(controllers::notes::routes()) .add_route(controllers::auth::routes()) .add_route(controllers::user::routes()) diff --git a/starters/rest-api/src/controllers/auth.rs b/starters/rest-api/src/controllers/auth.rs index dba78a3e9..9978d9d21 100644 --- a/starters/rest-api/src/controllers/auth.rs +++ b/starters/rest-api/src/controllers/auth.rs @@ -141,7 +141,7 @@ async fn login(State(ctx): State, Json(params): Json) - pub fn routes() -> Routes { Routes::new() - .prefix("auth") + .prefix("api/auth") .add("/register", post(register)) .add("/verify", post(verify)) .add("/login", post(login)) diff --git a/starters/rest-api/src/controllers/notes.rs b/starters/rest-api/src/controllers/notes.rs index f378fb4d8..c95aa3e39 100644 --- a/starters/rest-api/src/controllers/notes.rs +++ b/starters/rest-api/src/controllers/notes.rs @@ -66,7 +66,7 @@ pub async fn get_one(Path(id): Path, State(ctx): State) -> Resu pub fn routes() -> Routes { Routes::new() - .prefix("notes") + .prefix("api/notes") .add("/", get(list)) .add("/", post(add)) .add("/:id", get(get_one)) diff --git a/starters/rest-api/src/controllers/user.rs b/starters/rest-api/src/controllers/user.rs index 1f432ae9e..a7c0af334 100644 --- a/starters/rest-api/src/controllers/user.rs +++ b/starters/rest-api/src/controllers/user.rs @@ -10,5 +10,7 @@ async fn current(auth: auth::JWT, State(ctx): State) -> Result Routes { - Routes::new().prefix("user").add("/current", get(current)) + Routes::new() + .prefix("api/user") + .add("/current", get(current)) }