Skip to content

Commit d3f2927

Browse files
committed
feat: v16.0.0
1 parent e2190e7 commit d3f2927

File tree

13 files changed

+311
-119
lines changed

13 files changed

+311
-119
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hyperlane-quick-start"
3-
version = "15.0.0"
3+
version = "16.0.0"
44
readme = "README.md"
55
edition = "2024"
66
authors = ["root@ltpp.vip"]
@@ -34,8 +34,8 @@ hyperlane_plugin = { path = "plugin", version = "15.0.0" }
3434
hyperlane_resources = { path = "resources", version = "15.0.0" }
3535

3636
tracing = "0.1.44"
37-
hyperlane = "15.0.1"
38-
hyperlane-utils = "21.0.1"
37+
hyperlane = "17.3.2"
38+
hyperlane-utils = "22.0.0"
3939
serde = { version = "1.0.228", features = ["derive"] }
4040

4141
[dependencies]

application/exception/impl.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::*;
33
impl ServerHook for TaskPanicHook {
44
#[task_panic_data(task_panic_data)]
55
#[instrument_trace]
6-
async fn new(ctx: &Context) -> Self {
6+
async fn new(ctx: &mut Context) -> Self {
77
Self {
88
content_type: ContentType::format_content_type_with_charset(APPLICATION_JSON, UTF8),
99
response_body: task_panic_data.to_string(),
@@ -19,8 +19,8 @@ impl ServerHook for TaskPanicHook {
1919
)]
2020
#[epilogue_macros(response_body(&response_body), try_send)]
2121
#[instrument_trace]
22-
async fn handle(self, ctx: &Context) {
23-
debug!("TaskPanicHook request => {}", ctx.get_request().await);
22+
async fn handle(self, ctx: &mut Context) {
23+
debug!("TaskPanicHook request => {}", ctx.get_request());
2424
error!("TaskPanicHook => {}", self.get_response_body());
2525
let api_response: ApiResponse<()> =
2626
ApiResponse::error_with_code(ResponseCode::InternalError, self.get_response_body());
@@ -31,7 +31,7 @@ impl ServerHook for TaskPanicHook {
3131
impl ServerHook for RequestErrorHook {
3232
#[request_error_data(request_error_data)]
3333
#[instrument_trace]
34-
async fn new(_ctx: &Context) -> Self {
34+
async fn new(_ctx: &mut Context) -> Self {
3535
Self {
3636
response_status_code: request_error_data.get_http_status_code(),
3737
content_type: ContentType::format_content_type_with_charset(APPLICATION_JSON, UTF8),
@@ -49,14 +49,14 @@ impl ServerHook for RequestErrorHook {
4949
)]
5050
#[epilogue_macros(response_body(&response_body), try_send)]
5151
#[instrument_trace]
52-
async fn handle(self, ctx: &Context) {
52+
async fn handle(self, ctx: &mut Context) {
5353
if self.get_response_status_code() == HttpStatus::BadRequest.code() {
54-
ctx.aborted().await;
54+
ctx.set_aborted(true);
5555
debug!("Context aborted");
5656
return;
5757
}
5858
if self.get_response_status_code() != HttpStatus::RequestTimeout.code() {
59-
debug!("RequestErrorHook request => {}", ctx.get_request().await);
59+
debug!("RequestErrorHook request => {}", ctx.get_request());
6060
error!("RequestErrorHook => {}", self.get_response_body());
6161
}
6262
let api_response: ApiResponse<()> =

application/middleware/request/impl.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ use super::*;
22

33
impl ServerHook for HttpRequestMiddleware {
44
#[instrument_trace]
5-
async fn new(_ctx: &Context) -> Self {
5+
async fn new(_ctx: &mut Context) -> Self {
66
Self
77
}
88

99
#[prologue_macros(
10-
reject(ctx.get_request_is_http_version().await),
10+
reject(ctx.get_request().get_version().is_http()),
1111
send,
1212
)]
1313
#[instrument_trace]
14-
async fn handle(self, ctx: &Context) {
15-
ctx.closed().await;
14+
async fn handle(self, ctx: &mut Context) {
15+
ctx.set_closed(true);
1616
}
1717
}
1818

1919
impl ServerHook for CrossMiddleware {
2020
#[instrument_trace]
21-
async fn new(_ctx: &Context) -> Self {
21+
async fn new(_ctx: &mut Context) -> Self {
2222
Self
2323
}
2424

@@ -27,12 +27,12 @@ impl ServerHook for CrossMiddleware {
2727
#[response_header(ACCESS_CONTROL_ALLOW_METHODS => ALL_METHODS)]
2828
#[response_header(ACCESS_CONTROL_ALLOW_HEADERS => WILDCARD_ANY)]
2929
#[instrument_trace]
30-
async fn handle(self, ctx: &Context) {}
30+
async fn handle(self, ctx: &mut Context) {}
3131
}
3232

3333
impl ServerHook for ResponseHeaderMiddleware {
3434
#[instrument_trace]
35-
async fn new(_ctx: &Context) -> Self {
35+
async fn new(_ctx: &mut Context) -> Self {
3636
Self
3737
}
3838

@@ -45,53 +45,53 @@ impl ServerHook for ResponseHeaderMiddleware {
4545
response_header("SocketAddr" => socket_addr_string)
4646
)]
4747
#[instrument_trace]
48-
async fn handle(self, ctx: &Context) {
48+
async fn handle(self, ctx: &mut Context) {
4949
let socket_addr_string: String = ctx.get_socket_addr_string().await;
5050
let content_type: String = ContentType::format_content_type_with_charset(TEXT_HTML, UTF8);
5151
}
5252
}
5353

5454
impl ServerHook for ResponseStatusCodeMiddleware {
5555
#[instrument_trace]
56-
async fn new(_ctx: &Context) -> Self {
56+
async fn new(_ctx: &mut Context) -> Self {
5757
Self
5858
}
5959

6060
#[response_status_code(200)]
6161
#[instrument_trace]
62-
async fn handle(self, ctx: &Context) {}
62+
async fn handle(self, ctx: &mut Context) {}
6363
}
6464

6565
impl ServerHook for ResponseBodyMiddleware {
6666
#[instrument_trace]
67-
async fn new(_ctx: &Context) -> Self {
67+
async fn new(_ctx: &mut Context) -> Self {
6868
Self
6969
}
7070

7171
#[epilogue_macros(response_body(TEMPLATES_INDEX_HTML.replace("{{ time }}", &time())))]
7272
#[instrument_trace]
73-
async fn handle(self, ctx: &Context) {}
73+
async fn handle(self, ctx: &mut Context) {}
7474
}
7575

7676
impl ServerHook for OptionMethodMiddleware {
7777
#[instrument_trace]
78-
async fn new(_ctx: &Context) -> Self {
78+
async fn new(_ctx: &mut Context) -> Self {
7979
Self
8080
}
8181

8282
#[prologue_macros(
83-
filter(ctx.get_request_is_options_method().await),
83+
filter(ctx.get_request().get_method().is_options()),
8484
send
8585
)]
8686
#[instrument_trace]
87-
async fn handle(self, ctx: &Context) {
88-
ctx.aborted().await;
87+
async fn handle(self, ctx: &mut Context) {
88+
ctx.set_aborted(true);
8989
}
9090
}
9191

9292
impl ServerHook for UpgradeMiddleware {
9393
#[instrument_trace]
94-
async fn new(_ctx: &Context) -> Self {
94+
async fn new(_ctx: &mut Context) -> Self {
9595
Self
9696
}
9797

@@ -102,9 +102,9 @@ impl ServerHook for UpgradeMiddleware {
102102
response_body(&vec![]),
103103
response_header(UPGRADE => WEBSOCKET),
104104
response_header(CONNECTION => UPGRADE),
105-
response_header(SEC_WEBSOCKET_ACCEPT => WebSocketFrame::generate_accept_key(ctx.try_get_request_header_back(SEC_WEBSOCKET_KEY).await.unwrap())),
105+
response_header(SEC_WEBSOCKET_ACCEPT => WebSocketFrame::generate_accept_key(ctx.get_request().get_header_back(SEC_WEBSOCKET_KEY))),
106106
send
107107
)]
108108
#[instrument_trace]
109-
async fn handle(self, ctx: &Context) {}
109+
async fn handle(self, ctx: &mut Context) {}
110110
}

application/middleware/response/impl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ use super::*;
22

33
impl ServerHook for SendMiddleware {
44
#[instrument_trace]
5-
async fn new(_ctx: &Context) -> Self {
5+
async fn new(_ctx: &mut Context) -> Self {
66
Self
77
}
88

99
#[prologue_macros(
10-
reject(ctx.get_request_is_ws_upgrade_type().await),
10+
reject(ctx.get_request().is_ws_upgrade_type()),
1111
try_send
1212
)]
1313
#[instrument_trace]
14-
async fn handle(self, ctx: &Context) {}
14+
async fn handle(self, ctx: &mut Context) {}
1515
}
1616

1717
impl ServerHook for LogMiddleware {
1818
#[instrument_trace]
19-
async fn new(_ctx: &Context) -> Self {
19+
async fn new(_ctx: &mut Context) -> Self {
2020
Self
2121
}
2222

2323
#[instrument_trace]
24-
async fn handle(self, ctx: &Context) {
24+
async fn handle(self, ctx: &mut Context) {
2525
let request_json: String = get_request_json(ctx).await;
2626
let response_json: String = get_response_json(ctx).await;
2727
info!("{request_json}");

application/utils/json/fn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use super::*;
22

33
#[instrument_trace]
4-
pub async fn get_request_json(ctx: &Context) -> String {
5-
let mut request: Request = ctx.get_request().await;
4+
pub async fn get_request_json(ctx: &mut Context) -> String {
5+
let mut request: Request = ctx.get_request().clone();
66
request.set_body(request.get_body().len().to_string().into_bytes());
77
serde_json::to_string(&request).unwrap_or(request.to_string())
88
}
99

1010
#[instrument_trace]
11-
pub async fn get_response_json(ctx: &Context) -> String {
12-
let mut response: Response = ctx.get_response().await;
11+
pub async fn get_response_json(ctx: &mut Context) -> String {
12+
let mut response: Response = ctx.get_response().clone();
1313
response.set_body(response.get_body().len().to_string().into_bytes());
1414
serde_json::to_string(&response).unwrap_or(response.to_string())
1515
}

application/utils/send/fn.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use super::*;
22

33
#[instrument_trace]
4-
pub async fn try_send_body_hook(ctx: &Context) -> Result<(), ResponseError> {
5-
let send_result: Result<(), ResponseError> = if ctx.get_request_is_ws_upgrade_type().await {
6-
let body: ResponseBody = ctx.get_response_body().await;
7-
let frame_list: Vec<ResponseBody> = WebSocketFrame::create_frame_list(&body);
4+
pub async fn try_send_body_hook(ctx: &mut Context) -> Result<(), ResponseError> {
5+
let send_result: Result<(), ResponseError> = if ctx.get_request().is_ws_upgrade_type() {
6+
let body: &ResponseBody = ctx.get_response().get_body();
7+
let frame_list: Vec<ResponseBody> = WebSocketFrame::create_frame_list(body);
88
ctx.try_send_body_list_with_data(&frame_list).await
99
} else {
1010
ctx.try_send_body().await
1111
};
1212
if send_result.is_err() {
13-
ctx.aborted().await.closed().await;
13+
ctx.set_aborted(true).set_closed(true);
1414
}
1515
send_result
1616
}

application/view/favicon/impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22

33
impl ServerHook for FaviconRoute {
44
#[instrument_trace]
5-
async fn new(_ctx: &Context) -> Self {
5+
async fn new(_ctx: &mut Context) -> Self {
66
Self
77
}
88

@@ -12,5 +12,5 @@ impl ServerHook for FaviconRoute {
1212
response_header(LOCATION => LOGO_IMG_URL)
1313
)]
1414
#[instrument_trace]
15-
async fn handle(self, ctx: &Context) {}
15+
async fn handle(self, ctx: &mut Context) {}
1616
}

bootstrap/framework/config/impl.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ use super::*;
33
impl BootstrapAsyncInit for ConfigBootstrap {
44
#[hyperlane(server_config: ServerConfig)]
55
async fn init() -> Self {
6-
let request_config: RequestConfig = RequestConfig::default();
6+
let mut request_config: RequestConfig = RequestConfig::default();
77
request_config
8-
.max_body_size(SERVER_REQUEST_MAX_BODY_SIZE)
9-
.await
10-
.http_read_timeout_ms(SERVER_REQUEST_HTTP_READ_TIMEOUT_MS)
11-
.await;
12-
server_config.host(SERVER_HOST).await;
13-
server_config.port(SERVER_PORT).await;
14-
server_config.ttl(SERVER_TTI).await;
15-
server_config.nodelay(SERVER_NODELAY).await;
8+
.set_max_body_size(SERVER_REQUEST_MAX_BODY_SIZE)
9+
.set_read_timeout_ms(SERVER_REQUEST_HTTP_READ_TIMEOUT_MS);
10+
server_config.set_address(Server::format_bind_address(SERVER_HOST, SERVER_PORT));
11+
server_config.set_ttl(SERVER_TTI);
12+
server_config.set_nodelay(SERVER_NODELAY);
1613
debug!("Server config {server_config:?}");
1714
info!("Server initialization successful");
1815
Self {

bootstrap/framework/server/impl.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22

33
impl ServerBootstrap {
44
async fn print_route_matcher(server: &Server) {
5-
let route_matcher: RouteMatcher = server.get_route_matcher().await;
5+
let route_matcher: &RouteMatcher = server.get_route_matcher();
66
for key in route_matcher.get_static_route().keys() {
77
info!("Static route {key}");
88
}
@@ -24,10 +24,8 @@ impl BootstrapAsyncInit for ServerBootstrap {
2424
async fn init() -> Self {
2525
let config: ConfigBootstrap = ConfigBootstrap::init().await;
2626
server
27-
.request_config(config.get_request_config().clone())
28-
.await
29-
.server_config(config.get_server_config().clone())
30-
.await;
27+
.request_config(*config.get_request_config())
28+
.server_config(config.get_server_config().clone());
3129
match server.run().await {
3230
Ok(server_hook) => {
3331
let host_port: String = format!("{SERVER_HOST}{COLON}{SERVER_PORT}");

0 commit comments

Comments
 (0)