apps
This commit is contained in:
@@ -24,19 +24,18 @@ impl ApiHandler {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn handle_request<B>(&self, req: Request<B>) -> Result<Response<Full<Bytes>>>
|
||||
where
|
||||
B: http_body::Body<Data = Bytes> + Send + 'static,
|
||||
B::Error: std::fmt::Display,
|
||||
{
|
||||
let path = req.uri().path();
|
||||
let method = req.method();
|
||||
pub async fn handle_request(
|
||||
&self,
|
||||
req: Request<http_body_util::Incoming>,
|
||||
) -> Result<Response<Full<Bytes>>> {
|
||||
// Extract path and method before consuming req
|
||||
let path = req.uri().path().to_string();
|
||||
let method = req.method().clone();
|
||||
|
||||
// Convert Incoming body to bytes using http_body_util::BodyExt
|
||||
// Convert body to bytes using http_body_util::BodyExt
|
||||
let (parts, body) = req.into_parts();
|
||||
// hyper::body::Incoming implements http_body::Body, and BodyExt extends it
|
||||
use http_body_util::BodyExt;
|
||||
let collected = body.collect().await
|
||||
let collected: http_body_util::Collected<Bytes> = body.collect().await
|
||||
.map_err(|_e| anyhow::anyhow!("Failed to read body"))?;
|
||||
let body_bytes = collected.to_bytes();
|
||||
|
||||
@@ -47,10 +46,10 @@ impl ApiHandler {
|
||||
|
||||
// Route requests
|
||||
match (method, path.as_str()) {
|
||||
(&Method::POST, "/rpc/v1") => {
|
||||
(Method::POST, "/rpc/v1") => {
|
||||
self.rpc_handler.handle(req_with_bytes).await
|
||||
}
|
||||
(&Method::GET, "/health") => {
|
||||
(Method::GET, "/health") => {
|
||||
Ok(Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.body(Full::new(Bytes::from("OK")))
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:84}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:84}, _>, TokioExecutor>
|
||||
@@ -0,0 +1,2 @@
|
||||
hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>: hyper::service::service::Service<http::request::Request<hyper::body::incoming::Incoming>>
|
||||
hyper_util::server::conn::auto::Connection<'_, TokioIo<tokio::net::TcpStream>, hyper::service::util::ServiceFn<{closure@archipelago/src/server.rs:43:42: 43:52}, _>, TokioExecutor>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user