1- use http:: header:: { self , ACCESS_CONTROL_ALLOW_ORIGIN , LOCATION } ;
1+ use http:: header:: {
2+ self , ACCESS_CONTROL_ALLOW_HEADERS , ACCESS_CONTROL_ALLOW_METHODS , ACCESS_CONTROL_ALLOW_ORIGIN ,
3+ CONTENT_TYPE , LOCATION ,
4+ } ;
25use hyper:: service:: Service ;
36use hyper:: { Body , Method , Request , Response , StatusCode } ;
47use std:: task:: Context ;
@@ -129,9 +132,9 @@ where
129132 fn handle_graphql_options ( _request : Request < Body > ) -> Response < Body > {
130133 Response :: builder ( )
131134 . status ( 200 )
132- . header ( "Access-Control-Allow-Origin" , "*" )
133- . header ( "Access-Control-Allow-Headers" , "Content-Type, User-Agent" )
134- . header ( "Access-Control-Allow-Methods" , "GET, OPTIONS, POST" )
135+ . header ( ACCESS_CONTROL_ALLOW_ORIGIN , "*" )
136+ . header ( ACCESS_CONTROL_ALLOW_HEADERS , "Content-Type, User-Agent" )
137+ . header ( ACCESS_CONTROL_ALLOW_METHODS , "GET, OPTIONS, POST" )
135138 . body ( Body :: from ( "" ) )
136139 . unwrap ( )
137140 }
@@ -157,7 +160,7 @@ where
157160 Response :: builder ( )
158161 . status ( StatusCode :: NOT_FOUND )
159162 . header ( ACCESS_CONTROL_ALLOW_ORIGIN , "*" )
160- . header ( "Content-Type" , "text/plain" )
163+ . header ( CONTENT_TYPE , "text/plain" )
161164 . body ( Body :: from ( "Not found\n " ) )
162165 . unwrap ( )
163166 }
@@ -228,7 +231,7 @@ where
228231
229232 Ok ( Response :: builder ( )
230233 . status ( 400 )
231- . header ( "Content-Type" , "text/plain" )
234+ . header ( CONTENT_TYPE , "text/plain" )
232235 . header ( ACCESS_CONTROL_ALLOW_ORIGIN , "*" )
233236 . body ( Body :: from ( format ! ( "Invalid request: {}" , err) ) )
234237 . unwrap ( ) )
@@ -238,7 +241,7 @@ where
238241
239242 Ok ( Response :: builder ( )
240243 . status ( 400 )
241- . header ( "Content-Type" , "text/plain" )
244+ . header ( CONTENT_TYPE , "text/plain" )
242245 . header ( ACCESS_CONTROL_ALLOW_ORIGIN , "*" )
243246 . body ( Body :: from ( format ! ( "Query error: {}" , err) ) )
244247 . unwrap ( ) )
@@ -248,7 +251,7 @@ where
248251
249252 Ok ( Response :: builder ( )
250253 . status ( 500 )
251- . header ( "Content-Type" , "text/plain" )
254+ . header ( CONTENT_TYPE , "text/plain" )
252255 . header ( ACCESS_CONTROL_ALLOW_ORIGIN , "*" )
253256 . body ( Body :: from ( format ! ( "Internal server error: {}" , err) ) )
254257 . unwrap ( ) )
0 commit comments