fn parse_request_bytes(byte_stream: &[u8], callback: fn(Request) -> Response) -> Response {
    let request = Request::try_from(byte_stream, None);
    match request {
        Ok(request) => callback(request),
        Err(e) => match e {
            RequestError::BodyWithoutPendingRequest => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(e.to_string()),
            ),
            RequestError::HeadersWithoutPendingRequest => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(e.to_string()),
            ),
            RequestError::InvalidHttpVersion(err_msg) => build_response(
                Version::default(),
                StatusCode::NotImplemented,
                Body::new(err_msg.to_string()),
            ),
            RequestError::InvalidUri(err_msg) => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(err_msg.to_string()),
            ),
            RequestError::InvalidHttpMethod(err_msg) => build_response(
                Version::default(),
                StatusCode::NotImplemented,
                Body::new(err_msg.to_string()),
            ),
            RequestError::InvalidRequest => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new("Invalid request.".to_string()),
            ),
            RequestError::HeaderError(err) => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(err.to_string()),
            ),
            RequestError::Overflow => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(e.to_string()),
            ),
            RequestError::Underflow => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(e.to_string()),
            ),
            RequestError::SizeLimitExceeded(_, _) => build_response(
                Version::default(),
                StatusCode::PayloadTooLarge,
                Body::new(e.to_string()),
            ),
        },
    }
}
/// Parses the request bytes and builds a `micro_http::Response` by the given callback function.
Parses the request bytes and builds a `micro_http::Response` by the given callback function.
Parses the request bytes and builds a ` micro_http :: Response ` by the given callback function .
fn parse_request_bytes(byte_stream: &[u8], callback: fn(Request) -> Response) -> Response {
    let request = Request::try_from(byte_stream, None);
    match request {
        Ok(request) => callback(request),
        Err(e) => match e {
            RequestError::BodyWithoutPendingRequest => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(e.to_string()),
            ),
            RequestError::HeadersWithoutPendingRequest => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(e.to_string()),
            ),
            RequestError::InvalidHttpVersion(err_msg) => build_response(
                Version::default(),
                StatusCode::NotImplemented,
                Body::new(err_msg.to_string()),
            ),
            RequestError::InvalidUri(err_msg) => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(err_msg.to_string()),
            ),
            RequestError::InvalidHttpMethod(err_msg) => build_response(
                Version::default(),
                StatusCode::NotImplemented,
                Body::new(err_msg.to_string()),
            ),
            RequestError::InvalidRequest => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new("Invalid request.".to_string()),
            ),
            RequestError::HeaderError(err) => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(err.to_string()),
            ),
            RequestError::Overflow => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(e.to_string()),
            ),
            RequestError::Underflow => build_response(
                Version::default(),
                StatusCode::BadRequest,
                Body::new(e.to_string()),
            ),
            RequestError::SizeLimitExceeded(_, _) => build_response(
                Version::default(),
                StatusCode::PayloadTooLarge,
                Body::new(e.to_string()),
            ),
        },
    }
}
fn parse_request_bytes ( byte_stream : & [ u8 ] , callback : fn ( Request ) -> Response ) -> Response { let request = Request :: try_from ( byte_stream , None ) ; match request { Ok ( request ) => callback ( request ) , Err ( e ) => match e { RequestError :: BodyWithoutPendingRequest => build_response ( Version :: default ( ) , StatusCode :: BadRequest , Body :: new ( e . to_string ( ) ) , ) , RequestError :: HeadersWithoutPendingRequest => build_response ( Version :: default ( ) , StatusCode :: BadRequest , Body :: new ( e . to_string ( ) ) , ) , RequestError :: InvalidHttpVersion ( err_msg ) => build_response ( Version :: default ( ) , StatusCode :: NotImplemented , Body :: new ( err_msg . to_string ( ) ) , ) , RequestError :: InvalidUri ( err_msg ) => build_response ( Version :: default ( ) , StatusCode :: BadRequest , Body :: new ( err_msg . to_string ( ) ) , ) , RequestError :: InvalidHttpMethod ( err_msg ) => build_response ( Version :: default ( ) , StatusCode :: NotImplemented , Body :: new ( err_msg . to_string ( ) ) , ) , RequestError :: InvalidRequest => build_response ( Version :: default ( ) , StatusCode :: BadRequest , Body :: new ( " " . to_string ( ) ) , ) , RequestError :: HeaderError ( err ) => build_response ( Version :: default ( ) , StatusCode :: BadRequest , Body :: new ( err . to_string ( ) ) , ) , RequestError :: Overflow => build_response ( Version :: default ( ) , StatusCode :: BadRequest , Body :: new ( e . to_string ( ) ) , ) , RequestError :: Underflow => build_response ( Version :: default ( ) , StatusCode :: BadRequest , Body :: new ( e . to_string ( ) ) , ) , RequestError :: SizeLimitExceeded ( _ , _ ) => build_response ( Version :: default ( ) , StatusCode :: PayloadTooLarge , Body :: new ( e . to_string ( ) ) , ) , } , } }
Parses the request bytes and builds a `micro_http::Response` by the given callback function.
Parses the request bytes and builds a ` micro_http :: Response ` by the given callback function .
byte_stream
&[u8]
callback
fn(Request) -> Response
byte_stream
&[u8]
callback
fn(Request) -> Response