File tree 4 files changed +18
-11
lines changed
src/lib/presets/m2/handlers
4 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 1
- use actix_web:: http:: StatusCode ;
2
1
use actix_web:: HttpRequest ;
3
2
use actix_web:: HttpResponse ;
4
3
use preset:: AppState ;
5
4
use presets:: m2:: state:: gather_state;
5
+ use actix_web:: http:: StatusCode ;
6
6
7
7
///
8
8
/// This handler will serve up JSON that
@@ -25,13 +25,6 @@ pub fn handle(req: &HttpRequest<AppState>) -> HttpResponse {
25
25
26
26
match output {
27
27
Ok ( t) => HttpResponse :: Ok ( ) . content_type ( "application/json" ) . body ( t) ,
28
- Err ( e) => HttpResponse :: Ok ( )
29
- . content_type ( "application/json" )
30
- . status ( StatusCode :: from_u16 ( 500 ) . expect ( "can set 500 resp code" ) )
31
- . body (
32
- serde_json:: to_string_pretty ( & json ! ( {
33
- "message" : e. to_string( )
34
- } ) ) . unwrap ( ) ,
35
- ) ,
28
+ Err ( e) => super :: err_response:: create ( e) ,
36
29
}
37
30
}
Original file line number Diff line number Diff line change
1
+ use actix_web:: http:: StatusCode ;
2
+ use actix_web:: HttpResponse ;
3
+
4
+ pub fn create ( message : String ) -> HttpResponse {
5
+ HttpResponse :: Ok ( )
6
+ . content_type ( "application/json" )
7
+ . status ( StatusCode :: from_u16 ( 500 ) . expect ( "can set 500 resp code" ) )
8
+ . body (
9
+ serde_json:: to_string_pretty ( & json ! ( {
10
+ "message" : message
11
+ } ) ) . unwrap ( ) ,
12
+ )
13
+ }
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ pub fn handle(req: &HttpRequest<AppState>) -> HttpResponse {
23
23
} ;
24
24
25
25
match output {
26
- Ok ( t) => HttpResponse :: Ok ( ) . content_type ( "text/plain " ) . body ( t) ,
27
- Err ( _e ) => HttpResponse :: Ok ( ) . content_type ( "text/plain" ) . body ( "NAH" ) ,
26
+ Ok ( t) => HttpResponse :: Ok ( ) . content_type ( "application/javascript " ) . body ( t) ,
27
+ Err ( e ) => super :: err_response :: create ( e ) ,
28
28
}
29
29
}
Original file line number Diff line number Diff line change @@ -7,3 +7,4 @@ pub mod req_capture;
7
7
pub mod requests;
8
8
pub mod seed;
9
9
pub mod serve_r_js;
10
+ pub mod err_response;
You can’t perform that action at this time.
0 commit comments