Move the route mods to matching URI namespaces
This commit is contained in:
parent
ca6bc8d7d1
commit
4ed35b652e
|
@ -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)
|
||||
})
|
||||
}
|
|
@ -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])
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue