-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
182a93e
commit 0adf112
Showing
25 changed files
with
235 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
mod content_type; | ||
mod forwarded_for; | ||
mod mime; | ||
mod received_at; | ||
mod remote; | ||
mod request_meta; | ||
mod signed_json; | ||
mod start_time; | ||
|
||
pub use self::content_type::*; | ||
pub use self::forwarded_for::*; | ||
pub use self::mime::*; | ||
pub use self::received_at::*; | ||
pub use self::remote::*; | ||
pub use self::request_meta::*; | ||
pub use self::signed_json::*; | ||
pub use self::start_time::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use std::convert::Infallible; | ||
|
||
use axum::extract::FromRequestParts; | ||
use axum::http::request::Parts; | ||
use axum::Extension; | ||
use chrono::{DateTime, Utc}; | ||
|
||
/// The time at which the request started. | ||
#[derive(Clone, Copy, Debug)] | ||
pub struct ReceivedAt(pub DateTime<Utc>); | ||
|
||
impl ReceivedAt { | ||
pub fn now() -> Self { | ||
Self(Utc::now()) | ||
} | ||
} | ||
|
||
#[axum::async_trait] | ||
impl<S> FromRequestParts<S> for ReceivedAt | ||
where | ||
S: Send + Sync, | ||
{ | ||
type Rejection = Infallible; | ||
|
||
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> { | ||
let Extension(start_time) = Extension::from_request_parts(parts, state) | ||
.await | ||
.expect("ReceivedAt middleware is not configured"); | ||
|
||
Ok(start_time) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.