Skip to content

Commit 5d5a3d4

Browse files
committed
feat: server header
1 parent 3af01a5 commit 5d5a3d4

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

frameworks/Rust/hyperlane/Cargo.lock

Lines changed: 1 addition & 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ bb8-postgres = "0.9.0"
2424
rand = "0.9.0"
2525
tokio-postgres = { version = "0.7.13", features = ["with-uuid-0_8"] }
2626
chrono = "0.4.40"
27+
serde = "1.0.219"
2728

2829
[profile.dev]
2930
incremental = false

frameworks/Rust/hyperlane/src/db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub async fn random_world_row() -> Result<QueryRow, Box<dyn std::error::Error>>
129129
if let Some(rows) = connection.query_opt(&stmt, &[&random_id]).await? {
130130
let id: i32 = rows.get(0);
131131
let random_number: i32 = rows.get(1);
132-
return Ok((id, random_number));
132+
return Ok(QueryRow::new(id, random_number));
133133
}
134-
return Ok((0, 0));
134+
return Ok(QueryRow::new(0, 0));
135135
}

frameworks/Rust/hyperlane/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub(crate) use constant::*;
1515
pub(crate) use db::*;
1616
pub(crate) use hyperlane::{
1717
once_cell::sync::Lazy,
18+
serde::*,
1819
serde_json::json,
1920
tokio::sync::{RwLock, RwLockWriteGuard},
2021
*,
@@ -25,6 +26,7 @@ pub(crate) use rand::Rng;
2526
pub(crate) use request_middleware::*;
2627
pub(crate) use response_middleware::*;
2728
pub(crate) use route::*;
29+
2830
pub(crate) use server::*;
2931
pub(crate) use std::time::SystemTime;
3032
pub(crate) use std::{io, sync::Arc};

frameworks/Rust/hyperlane/src/type.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,20 @@ use crate::*;
22

33
pub type DbPoolConnection = bb8::Pool<PostgresConnectionManager<NoTls>>;
44
pub type DbConnection<'a> = PooledConnection<'a, PostgresConnectionManager<NoTls>>;
5-
pub type QueryRow = (i32, i32);
65
pub type Queries = usize;
6+
7+
#[allow(bad_style)]
8+
#[derive(Serialize)]
9+
pub struct QueryRow {
10+
id: i32,
11+
randomNumber: i32,
12+
}
13+
14+
impl QueryRow {
15+
pub fn new(id: i32, random_number: i32) -> Self {
16+
Self {
17+
id: id,
18+
randomNumber: random_number,
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)