Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Infallible to LambdaError on hyper #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 4 additions & 6 deletions src/hyper014.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::request::LambdaHttpEvent;
use core::convert::TryFrom;
use core::future::Future;
use lambda_runtime::{Error as LambdaError, LambdaEvent, Service as LambdaService};
use std::convert::Infallible;
use std::pin::Pin;

type HyperRequest = hyper::Request<hyper::Body>;
Expand Down Expand Up @@ -69,7 +68,7 @@ type HyperResponse<B> = hyper::Response<B>;
/// ```
pub async fn run_hyper_on_lambda<S, B>(svc: S) -> Result<(), LambdaError>
where
S: hyper::service::Service<HyperRequest, Response = HyperResponse<B>, Error = Infallible>
S: hyper::service::Service<HyperRequest, Response = HyperResponse<B>, Error = LambdaError>
+ 'static,
B: hyper::body::HttpBody,
<B as hyper::body::HttpBody>::Error: std::error::Error + Send + Sync + 'static,
Expand All @@ -81,20 +80,19 @@ where
/// Lambda_runtime handler for hyper
struct HyperHandler<S, B>(S)
where
S: hyper::service::Service<HyperRequest, Response = HyperResponse<B>, Error = Infallible>
+ 'static,
S: hyper::service::Service<HyperRequest, Response = HyperResponse<B>> + 'static,
B: hyper::body::HttpBody,
<B as hyper::body::HttpBody>::Error: std::error::Error + Send + Sync + 'static;

impl<S, B> LambdaService<LambdaEvent<LambdaHttpEvent<'_>>> for HyperHandler<S, B>
where
S: hyper::service::Service<HyperRequest, Response = HyperResponse<B>, Error = Infallible>
S: hyper::service::Service<HyperRequest, Response = HyperResponse<B>, Error = LambdaError>
+ 'static,
B: hyper::body::HttpBody,
<B as hyper::body::HttpBody>::Error: std::error::Error + Send + Sync + 'static,
{
type Response = serde_json::Value;
type Error = Infallible;
type Error = LambdaError;
type Future = Pin<Box<dyn Future<Output = Result<serde_json::Value, Self::Error>>>>;

/// Returns Poll::Ready when servie can process more requrests.
Expand Down