Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ napi-support = ["dep:napi", "dep:napi-derive", "dep:napi-build"]
napi-build = { version = "2", optional = true }

[dependencies]
async-trait = "0.1.88"
bytes = "1.10.1"
http = "1.0"
# http-body = "1.0"
Expand Down
16 changes: 1 addition & 15 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
//!
//! struct HelloHandler;
//!
//! #[async_trait::async_trait]
//! impl Handler for HelloHandler {
//! type Error = std::convert::Infallible;
//!
Expand All @@ -41,11 +40,10 @@
//! header_value: &'static str,
//! }
//!
//! #[async_trait::async_trait]
//! impl<H, B> Handler<B> for AddHeaderHandler<H>
//! where
//! H: Handler<B> + std::marker::Sync,
//! for<'async_trait> B: std::marker::Send + 'async_trait
//! B: std::marker::Send
//! {
//! type Error = H::Error;
//!
Expand All @@ -62,7 +60,6 @@
//! // Usage
//! struct ApiHandler;
//!
//! #[async_trait::async_trait]
//! impl Handler for ApiHandler {
//! type Error = std::convert::Infallible;
//! async fn handle(&self, _req: http::Request<BytesMut>) -> Result<http::Response<BytesMut>, Self::Error> {
Expand Down Expand Up @@ -101,7 +98,6 @@ use bytes::BytesMut;
///
/// struct MyHandler;
///
/// #[async_trait::async_trait]
/// impl Handler for MyHandler {
/// type Error = std::convert::Infallible;
///
Expand All @@ -122,7 +118,6 @@ use bytes::BytesMut;
///
/// struct StringHandler;
///
/// #[async_trait::async_trait]
/// impl Handler<String> for StringHandler {
/// type Error = std::convert::Infallible;
///
Expand All @@ -137,7 +132,6 @@ use bytes::BytesMut;
/// }
/// }
/// ```
#[async_trait::async_trait]
pub trait Handler<B = BytesMut> {
/// The error type returned by the handler
type Error;
Expand All @@ -157,7 +151,6 @@ mod tests {
/// Example handler that echoes the request body
pub struct EchoHandler;

#[async_trait::async_trait]
impl Handler<Bytes> for EchoHandler {
type Error = http::Error;

Expand Down Expand Up @@ -187,7 +180,6 @@ mod tests {
/// Test handler that adds logging
struct LoggingHandler;

#[async_trait::async_trait]
impl Handler<Bytes> for LoggingHandler {
type Error = String;

Expand Down Expand Up @@ -229,7 +221,6 @@ mod tests {
/// Test handler that uses socket info
struct SocketAwareHandler;

#[async_trait::async_trait]
impl Handler<Bytes> for SocketAwareHandler {
type Error = String;

Expand Down Expand Up @@ -285,7 +276,6 @@ mod tests {
/// Test handler that returns errors
struct ErrorHandler;

#[async_trait::async_trait]
impl Handler<Bytes> for ErrorHandler {
type Error = String;

Expand Down Expand Up @@ -313,7 +303,6 @@ mod tests {
/// Test handler that sets an exception
struct ExceptionHandler;

#[async_trait::async_trait]
impl Handler<Bytes> for ExceptionHandler {
type Error = std::convert::Infallible;

Expand Down Expand Up @@ -351,7 +340,6 @@ mod tests {
/// Test handler that works with String bodies
struct StringBodyHandler;

#[async_trait::async_trait]
impl Handler<String> for StringBodyHandler {
type Error = std::convert::Infallible;

Expand Down Expand Up @@ -430,7 +418,6 @@ mod tests {
/// Generic echo handler that works with any cloneable body type
pub struct GenericEchoHandler;

#[async_trait::async_trait]
impl Handler<Bytes> for GenericEchoHandler {
type Error = http::Error;

Expand All @@ -444,7 +431,6 @@ mod tests {
}
}

#[async_trait::async_trait]
impl Handler<Vec<u8>> for GenericEchoHandler {
type Error = http::Error;

Expand Down