@@ -4,7 +4,10 @@ use hyper::{
4
4
} ;
5
5
use std:: net:: SocketAddr ;
6
6
7
- use super :: { callbacks:: call_http, types:: WSGIScope as Scope } ;
7
+ use super :: {
8
+ callbacks:: { call_rtb_http, call_rtt_http} ,
9
+ types:: WSGIScope as Scope ,
10
+ } ;
8
11
use crate :: {
9
12
callbacks:: CallbackWrapper ,
10
13
http:: { response_500, HV_SERVER } ,
@@ -26,16 +29,15 @@ fn build_response(status: i32, pyheaders: Vec<(String, String)>, body: Body) ->
26
29
res
27
30
}
28
31
29
- pub ( crate ) async fn handle (
32
+ pub ( crate ) async fn handle_rtt (
30
33
_rt : RuntimeRef ,
31
34
callback : CallbackWrapper ,
32
35
server_addr : SocketAddr ,
33
36
client_addr : SocketAddr ,
34
37
req : Request < Body > ,
35
38
scheme : & str ,
36
39
) -> Response < Body > {
37
- let scope = Scope :: new ( scheme, server_addr, client_addr, req) . await ;
38
- if let Ok ( res) = call_http ( callback, scope) . await {
40
+ if let Ok ( res) = call_rtt_http ( callback, Scope :: new ( scheme, server_addr, client_addr, req) . await ) . await {
39
41
if let Ok ( ( status, headers, body) ) = res {
40
42
return build_response ( status, headers, body) ;
41
43
}
@@ -45,3 +47,20 @@ pub(crate) async fn handle(
45
47
}
46
48
response_500 ( )
47
49
}
50
+
51
+ pub ( crate ) async fn handle_rtb (
52
+ _rt : RuntimeRef ,
53
+ callback : CallbackWrapper ,
54
+ server_addr : SocketAddr ,
55
+ client_addr : SocketAddr ,
56
+ req : Request < Body > ,
57
+ scheme : & str ,
58
+ ) -> Response < Body > {
59
+ match call_rtb_http ( callback, Scope :: new ( scheme, server_addr, client_addr, req) . await ) {
60
+ Ok ( ( status, headers, body) ) => build_response ( status, headers, body) ,
61
+ _ => {
62
+ log:: warn!( "Application callable raised an exception" ) ;
63
+ response_500 ( )
64
+ }
65
+ }
66
+ }
0 commit comments