-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
156 additions
and
221 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
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.
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,31 @@ | ||
use std::collections::HashMap; | ||
use std::time::{SystemTime, UNIX_EPOCH}; | ||
|
||
use bytes::Bytes; | ||
|
||
|
||
/// important parts of an HTTP request | ||
pub struct RawRequest { | ||
pub cookies: HashMap<String, String>, | ||
pub headers: HashMap<String, String>, | ||
pub body: Bytes, | ||
} | ||
|
||
/// important parts of an HTTP response | ||
pub struct RawResponse { | ||
pub status: u16, | ||
pub cookies: HashMap<String, String>, | ||
pub headers: HashMap<String, String>, | ||
pub body: Bytes, | ||
} | ||
|
||
|
||
/// timestamp snowflake ID generator | ||
/// TODO: use database instead of app server | ||
pub fn get_millis() -> u64 { | ||
let start = SystemTime::now(); | ||
let since_the_epoch = start.duration_since(UNIX_EPOCH) | ||
.expect("Time went backwards"); | ||
return since_the_epoch.as_secs() * 1000 + | ||
since_the_epoch.subsec_nanos() as u64 / 1_000_000 << 22; | ||
} |
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
Oops, something went wrong.