Move the route mods to matching URI namespaces

This commit is contained in:
Alex Wright 2021-07-11 16:45:58 +00:00
parent ca6bc8d7d1
commit 4ed35b652e
2 changed files with 6 additions and 6 deletions

View File

@ -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<String> {
juniper_rocket::graphiql_source("/graphql", None)
juniper_rocket::graphiql_source("/graphql/", None)
}
#[rocket::get("/graphql?<request>")]
#[rocket::get("/?<request>")]
fn get_graphql_handler(
context: &State<Database>,
request: juniper_rocket::GraphQLRequest,
@ -19,7 +19,7 @@ fn get_graphql_handler(
request.execute_sync(&*schema, &*context)
}
#[rocket::post("/graphql", data = "<request>")]
#[rocket::post("/", data = "<request>")]
fn post_graphql_handler(
context: &State<Database>,
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)
})
}

View File

@ -22,6 +22,6 @@ fn people_detail(id: String, context: &State<Database>) -> Option<Json<Person>>
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])
})
}