6
6
//! pass them to the rest of the service and write the responses back.
7
7
use crate :: authenticators:: Authenticate ;
8
8
use crate :: back:: dispatcher:: Dispatcher ;
9
+ use crate :: front:: listener:: Connection ;
9
10
use derivative:: Derivative ;
10
11
use log:: { info, trace} ;
11
12
use parsec_interface:: requests:: AuthType ;
12
13
use parsec_interface:: requests:: ResponseStatus ;
13
14
use parsec_interface:: requests:: { Request , Response } ;
14
15
use std:: collections:: HashMap ;
15
16
use std:: io:: { Error , ErrorKind , Result } ;
16
- use std:: io:: { Read , Write } ;
17
17
18
18
/// Read and verify request from IPC stream
19
19
///
@@ -40,17 +40,17 @@ impl FrontEndHandler {
40
40
///
41
41
/// If an error occurs during (un)marshalling, no operation will be performed and the
42
42
/// method will return.
43
- pub fn handle_request < T : Read + Write > ( & self , mut stream : T ) {
43
+ pub fn handle_request ( & self , mut connection : Connection ) {
44
44
trace ! ( "handle_request ingress" ) ;
45
45
// Read bytes from stream
46
46
// De-Serialise bytes into a request
47
- let request = match Request :: read_from_stream ( & mut stream, self . body_len_limit ) {
47
+ let request = match Request :: read_from_stream ( & mut connection . stream , self . body_len_limit ) {
48
48
Ok ( request) => request,
49
49
Err ( status) => {
50
50
format_error ! ( "Failed to read request" , status) ;
51
51
52
52
let response = Response :: from_status ( status) ;
53
- if let Err ( status) = response. write_to_stream ( & mut stream) {
53
+ if let Err ( status) = response. write_to_stream ( & mut connection . stream ) {
54
54
format_error ! ( "Failed to write response" , status) ;
55
55
}
56
56
return ;
@@ -63,7 +63,7 @@ impl FrontEndHandler {
63
63
// Otherwise find an authenticator that is capable to authenticate the request
64
64
} else if let Some ( authenticator) = self . authenticators . get ( & request. header . auth_type ) {
65
65
// Authenticate the request
66
- match authenticator. authenticate ( & request. auth ) {
66
+ match authenticator. authenticate ( & request. auth , connection . metadata ) {
67
67
// Send the request to the dispatcher
68
68
// Get a response back
69
69
Ok ( app_name) => ( Some ( app_name) , None ) ,
@@ -102,7 +102,7 @@ impl FrontEndHandler {
102
102
103
103
// Serialise the response into bytes
104
104
// Write bytes to stream
105
- match response. write_to_stream ( & mut stream) {
105
+ match response. write_to_stream ( & mut connection . stream ) {
106
106
Ok ( _) => {
107
107
if crate :: utils:: GlobalConfig :: log_error_details ( ) {
108
108
if let Some ( app_name_string) = app_name {
0 commit comments