pub fn create_response(buffer: Buffer, files: StaticFiles) -> Vec<u8> {
    let mut response = Response::default_ok();

    let request = parse_request(buffer.to_vec());
    let request = match request {
        Ok(request) => request,
        Err(error) => {
            println!("{}", error);
            return Response::default_bad_request().make_sendable();
        }
    };

    let req_file = request.request_identifiers.path;
    let file = match files.get(&req_file) {
        Some(file) => file,
        None => {
            println!("Requested source could not be found");
            return Response::default_not_found().make_sendable();
        }
    };
    response.add_content_type(req_file);
    response.body = file.clone();
    response.make_sendable()
}
/// Creates a response according to the requested ressource
Creates a response according to the requested ressource
Creates a response according to the requested ressource
pub fn create_response(buffer: Buffer, files: StaticFiles) -> Vec<u8> {
    let mut response = Response::default_ok();
    let request = parse_request(buffer.to_vec());
    let request = match request {
        Ok(request) => request,
        Err(error) => {
            println!("{}", error);
            return Response::default_bad_request().make_sendable();
        }
    };
    let req_file = request.request_identifiers.path;
    let file = match files.get(&req_file) {
        Some(file) => file,
        None => {
            println!("Requested source could not be found");
            return Response::default_not_found().make_sendable();
        }
    };
    response.add_content_type(req_file);
    response.body = file.clone();
    response.make_sendable()
}
pub fn create_response ( buffer : Buffer , files : StaticFiles ) -> Vec < u8 > { let mut response = Response :: default_ok ( ) ; let request = parse_request ( buffer . to_vec ( ) ) ; let request = match request { Ok ( request ) => request , Err ( error ) => { println ! ( " " error ) ; return Response :: default_bad_request ( ) . make_sendable ( ) ; } } ; let req_file = request . request_identifiers . path ; let file = match files . get ( & req_file ) { Some ( file ) => file , None => { println ! ( " " ) ; return Response :: default_not_found ( ) . make_sendable ( ) ; } } ; response . add_content_type ( req_file ) ; response . body = file . clone ( ) ; response . make_sendable ( ) }
Creates a response according to the requested ressource
Creates a response according to the requested ressource
buffer
Buffer
files
StaticFiles
buffer
Buffer
files
StaticFiles