mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 07:53:00 +01:00
Merge pull request #153 from rofrol/add-header-for-juniper-example
Add header for juniper example
This commit is contained in:
commit
9d39f441e9
@ -14,7 +14,7 @@ extern crate env_logger;
|
|||||||
|
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
middleware, http, server,
|
middleware, http::{self, header::CONTENT_TYPE}, server,
|
||||||
App, AsyncResponder, HttpRequest, HttpResponse, HttpMessage, Error};
|
App, AsyncResponder, HttpRequest, HttpResponse, HttpMessage, Error};
|
||||||
use juniper::http::graphiql::graphiql_source;
|
use juniper::http::graphiql::graphiql_source;
|
||||||
use juniper::http::GraphQLRequest;
|
use juniper::http::GraphQLRequest;
|
||||||
@ -79,7 +79,7 @@ fn graphql(req: HttpRequest<State>) -> Box<Future<Item=HttpResponse, Error=Error
|
|||||||
.from_err()
|
.from_err()
|
||||||
.and_then(|res| {
|
.and_then(|res| {
|
||||||
match res {
|
match res {
|
||||||
Ok(user) => Ok(HttpResponse::Ok().body(user)),
|
Ok(user) => Ok(HttpResponse::Ok().header(CONTENT_TYPE, "application/json").body(user)),
|
||||||
Err(_) => Ok(HttpResponse::InternalServerError().into())
|
Err(_) => Ok(HttpResponse::InternalServerError().into())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user