From 4ed35b652e2026677c72f2ac125648198017fd42 Mon Sep 17 00:00:00 2001 From: Alex Wright Date: Sun, 11 Jul 2021 16:45:58 +0000 Subject: [PATCH] Move the route mods to matching URI namespaces --- src/graphql.rs | 10 +++++----- src/rest.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/graphql.rs b/src/graphql.rs index 9d0ee33..a43de15 100644 --- a/src/graphql.rs +++ b/src/graphql.rs @@ -5,12 +5,12 @@ use juniper::{ EmptySubscription }; use crate::model::Database; use crate::schema::{ Schema, Query, Mutations }; -#[rocket::get("/")] +#[rocket::get("/graphiql")] fn graphiql() -> content::Html { - juniper_rocket::graphiql_source("/graphql", None) + juniper_rocket::graphiql_source("/graphql/", None) } -#[rocket::get("/graphql?")] +#[rocket::get("/?")] fn get_graphql_handler( context: &State, request: juniper_rocket::GraphQLRequest, @@ -19,7 +19,7 @@ fn get_graphql_handler( request.execute_sync(&*schema, &*context) } -#[rocket::post("/graphql", data = "")] +#[rocket::post("/", data = "")] fn post_graphql_handler( context: &State, request: juniper_rocket::GraphQLRequest, @@ -36,7 +36,7 @@ pub fn stage() -> AdHoc { ); AdHoc::on_ignite("Add graphql endpoints", |rocket| async { rocket - .mount("/", rocket::routes![graphiql, get_graphql_handler, post_graphql_handler]) + .mount("/graphql", rocket::routes![graphiql, get_graphql_handler, post_graphql_handler]) .manage(schema) }) } \ No newline at end of file diff --git a/src/rest.rs b/src/rest.rs index 5bd7518..0425245 100644 --- a/src/rest.rs +++ b/src/rest.rs @@ -22,6 +22,6 @@ fn people_detail(id: String, context: &State) -> Option> pub fn stage() -> AdHoc { AdHoc::on_ignite("Add REST endpoint", |rocket| async { rocket - .mount("/", rocket::routes![people_detail, people_list]) + .mount("/rest", rocket::routes![people_detail, people_list]) }) } \ No newline at end of file