@@ -42,8 +42,8 @@ Check the LICENSE file for details.
42
42
43
43
use actix_web:: {
44
44
error:: { ErrorBadRequest , ErrorMethodNotAllowed , ErrorUnsupportedMediaType } ,
45
- http:: { header :: CONTENT_TYPE , Method } ,
46
- web, Error , FromRequest , HttpRequest , HttpResponse ,
45
+ http:: Method ,
46
+ web, Error , FromRequest , HttpMessage , HttpRequest , HttpResponse ,
47
47
} ;
48
48
use juniper:: {
49
49
http:: {
@@ -152,16 +152,12 @@ where
152
152
CtxT : Sync ,
153
153
S : ScalarValue + Send + Sync ,
154
154
{
155
- let content_type_header = req
156
- . headers ( )
157
- . get ( CONTENT_TYPE )
158
- . and_then ( |hv| hv. to_str ( ) . ok ( ) ) ;
159
- let req = match content_type_header {
160
- Some ( "application/json" ) => {
155
+ let req = match req. content_type ( ) {
156
+ "application/json" => {
161
157
let body = String :: from_request ( & req, & mut payload. into_inner ( ) ) . await ?;
162
158
serde_json:: from_str :: < GraphQLBatchRequest < S > > ( & body) . map_err ( ErrorBadRequest )
163
159
}
164
- Some ( "application/graphql" ) => {
160
+ "application/graphql" => {
165
161
let body = String :: from_request ( & req, & mut payload. into_inner ( ) ) . await ?;
166
162
Ok ( GraphQLBatchRequest :: Single ( GraphQLRequest :: new (
167
163
body, None , None ,
@@ -609,7 +605,7 @@ mod tests {
609
605
) ;
610
606
611
607
let req = test:: TestRequest :: post ( )
612
- . header ( "content-type" , "application/json" )
608
+ . header ( "content-type" , "application/json; charset=utf-8 " )
613
609
. set_payload (
614
610
r##"{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }"## ,
615
611
)
0 commit comments