Skip to content

Commit c94c451

Browse files
committed
HELP! The compiler hates me! :)
I'm able to implement FromRequest now that we're co-crated with Event, but I'm out of my async depth wrt what needs to go in from_request(). A little help, please?
1 parent fa5bbb4 commit c94c451

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ categories = ["web-programming", "encoding", "data-structures"]
1717
name = "cloudevents"
1818

1919
[features]
20-
ce-actix = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
20+
ce-actix = ["actix-web", "async-trait", "lazy_static", "bytes", "futures", "futures-util"]
2121
ce-reqwest = ["reqwest", "async-trait", "lazy_static", "bytes"]
2222
ce-rdkafka = ["rdkafka", "lazy_static", "bytes"]
2323
ce-warp = ["warp", "lazy_static", "bytes", "http", "hyper"]
@@ -41,6 +41,7 @@ async-trait = { version = "^0.1.33", optional = true }
4141
lazy_static = { version = "1.4.0", optional = true }
4242
bytes = { version = "^1.0", optional = true }
4343
futures = { version = "^0.3", optional = true }
44+
futures-util = { version = "^0.3", optional = true }
4445
http = { version = "0.2", optional = true }
4546
hyper = { version = "^0.14", optional = true }
4647

src/actix/server_request.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use actix_web::web::{Bytes, BytesMut};
1010
use actix_web::{web, HttpMessage, HttpRequest};
1111
use async_trait::async_trait;
1212
use futures::StreamExt;
13+
use futures_util::future::{ok, Ready};
1314
use std::convert::TryFrom;
1415

1516
/// Wrapper for [`HttpRequest`] that implements [`MessageDeserializer`] trait.
@@ -134,6 +135,17 @@ impl HttpRequestExt for HttpRequest {
134135
}
135136
}
136137

138+
impl actix_web::FromRequest for Event {
139+
type Config = ();
140+
type Error = actix_web::Error;
141+
type Future = Ready<std::result::Result<Event, actix_web::Error>>;
142+
143+
fn from_request(req: &HttpRequest, payload: &mut actix_web::dev::Payload) -> Self::Future {
144+
// TODO: request_to_event(req, web::Payload(payload.take()))
145+
ok(Event::default())
146+
}
147+
}
148+
137149
mod private {
138150
// Sealing the RequestExt
139151
pub trait Sealed {}

0 commit comments

Comments
 (0)