Skip to content

Commit 3af01a5

Browse files
committed
feat: server header
1 parent 70ff137 commit 3af01a5

File tree

5 files changed

+114
-2
lines changed

5 files changed

+114
-2
lines changed

frameworks/Rust/hyperlane/Cargo.lock

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/Rust/hyperlane/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ bb8 = "0.9.0"
2323
bb8-postgres = "0.9.0"
2424
rand = "0.9.0"
2525
tokio-postgres = { version = "0.7.13", features = ["with-uuid-0_8"] }
26+
chrono = "0.4.40"
2627

2728
[profile.dev]
2829
incremental = false
@@ -40,4 +41,4 @@ lto = true
4041
panic = "unwind"
4142
debug = false
4243
codegen-units = 1
43-
strip = "debuginfo"
44+
strip = "debuginfo"

frameworks/Rust/hyperlane/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ pub(crate) mod response_middleware;
66
pub(crate) mod route;
77
pub(crate) mod server;
88
pub(crate) mod r#type;
9+
pub(crate) mod utils;
910

1011
pub(crate) use bb8::{Pool, PooledConnection};
1112
pub(crate) use bb8_postgres::PostgresConnectionManager;
13+
pub(crate) use chrono::{DateTime, Utc};
1214
pub(crate) use constant::*;
1315
pub(crate) use db::*;
1416
pub(crate) use hyperlane::{
@@ -24,8 +26,10 @@ pub(crate) use request_middleware::*;
2426
pub(crate) use response_middleware::*;
2527
pub(crate) use route::*;
2628
pub(crate) use server::*;
29+
pub(crate) use std::time::SystemTime;
2730
pub(crate) use std::{io, sync::Arc};
2831
pub(crate) use tokio_postgres::{Config, NoTls, Row, Statement};
32+
pub(crate) use utils::*;
2933

3034
#[tokio::main]
3135
async fn main() {

frameworks/Rust/hyperlane/src/request_middleware.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ pub async fn request(controller_data: ControllerData) {
44
let _ = controller_data
55
.set_response_header(CONNECTION, CONNECTION_KEEP_ALIVE)
66
.await
7-
.set_request_header(CONTENT_TYPE, APPLICATION_JSON)
7+
.set_request_header(
8+
CONTENT_TYPE,
9+
format!("{}; {}", APPLICATION_JSON, CHARSET_UTF_8),
10+
)
811
.await
912
.set_response_header(SERVER, HYPERLANE)
1013
.await
14+
.set_response_header(DATE, generate_rfc1123_timestamp())
15+
.await
1116
.set_response_status_code(200)
1217
.await;
1318
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use crate::*;
2+
3+
pub fn generate_rfc1123_timestamp() -> String {
4+
let now: DateTime<Utc> = SystemTime::now().into();
5+
now.format("%a, %d %b %Y %H:%M:%S GMT").to_string()
6+
}

0 commit comments

Comments
 (0)