Skip to content

Commit 243db18

Browse files
committed
Implement Default trait
1 parent 400dd5d commit 243db18

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ impl From<&str> for LambdaInvokeMode {
6565
}
6666
}
6767

68-
#[derive(Default)]
6968
pub struct AdapterOptions {
7069
pub host: String,
7170
pub port: String,
@@ -79,8 +78,8 @@ pub struct AdapterOptions {
7978
pub invoke_mode: LambdaInvokeMode,
8079
}
8180

82-
impl AdapterOptions {
83-
pub fn default() -> Self {
81+
impl Default for AdapterOptions {
82+
fn default() -> Self {
8483
AdapterOptions {
8584
host: "127.0.0.1".to_string(),
8685
port: "8080".to_string(),
@@ -94,7 +93,9 @@ impl AdapterOptions {
9493
invoke_mode: LambdaInvokeMode::Buffered,
9594
}
9695
}
96+
}
9797

98+
impl AdapterOptions {
9899
pub fn from_env() -> Self {
99100
AdapterOptions {
100101
host: env::var("AWS_LWA_HOST").unwrap_or(env::var("HOST").unwrap_or_else(|_| "127.0.0.1".to_string())),
@@ -384,7 +385,7 @@ mod tests {
384385
port: app_server.port().to_string(),
385386
readiness_check_port: app_server.port().to_string(),
386387
readiness_check_path: "/healthcheck".to_string(),
387-
..AdapterOptions::default()
388+
..Default::default()
388389
};
389390

390391
// Initialize adapter and do readiness check
@@ -416,7 +417,7 @@ mod tests {
416417
port: app_server.port().to_string(),
417418
readiness_check_port: app_server.port().to_string(),
418419
readiness_check_path: "/healthcheck".to_string(),
419-
..AdapterOptions::default()
420+
..Default::default()
420421
};
421422

422423
// Initialize adapter and do readiness check
@@ -449,7 +450,7 @@ mod tests {
449450
readiness_check_port: app_server.port().to_string(),
450451
readiness_check_path: "/healthcheck".to_string(),
451452
readiness_check_min_unhealthy_status: 400,
452-
..AdapterOptions::default()
453+
..Default::default()
453454
};
454455

455456
// Initialize adapter and do readiness check

tests/integ_tests/main.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async fn test_http_readiness_check() {
110110
port: app_server.port().to_string(),
111111
readiness_check_port: app_server.port().to_string(),
112112
readiness_check_path: "/healthcheck".to_string(),
113-
..AdapterOptions::default()
113+
..Default::default()
114114
};
115115

116116
// Initialize adapter and do readiness check
@@ -136,7 +136,7 @@ async fn test_http_basic_request() {
136136
port: app_server.port().to_string(),
137137
readiness_check_port: app_server.port().to_string(),
138138
readiness_check_path: "/healthcheck".to_string(),
139-
..AdapterOptions::default()
139+
..Default::default()
140140
});
141141

142142
// // Call the adapter service with basic request
@@ -175,7 +175,7 @@ async fn test_http_headers() {
175175
port: app_server.port().to_string(),
176176
readiness_check_port: app_server.port().to_string(),
177177
readiness_check_path: "/healthcheck".to_string(),
178-
..AdapterOptions::default()
178+
..Default::default()
179179
});
180180

181181
// Prepare request
@@ -219,7 +219,7 @@ async fn test_http_path_encoding() {
219219
port: app_server.port().to_string(),
220220
readiness_check_port: app_server.port().to_string(),
221221
readiness_check_path: "/healthcheck".to_string(),
222-
..AdapterOptions::default()
222+
..Default::default()
223223
});
224224

225225
// Prepare request
@@ -261,7 +261,7 @@ async fn test_http_query_params() {
261261
port: app_server.port().to_string(),
262262
readiness_check_port: app_server.port().to_string(),
263263
readiness_check_path: "/healthcheck".to_string(),
264-
..AdapterOptions::default()
264+
..Default::default()
265265
});
266266

267267
// Prepare request
@@ -312,7 +312,7 @@ async fn test_http_post_put_delete() {
312312
port: app_server.port().to_string(),
313313
readiness_check_port: app_server.port().to_string(),
314314
readiness_check_path: "/healthcheck".to_string(),
315-
..AdapterOptions::default()
315+
..Default::default()
316316
});
317317

318318
// Prepare requests
@@ -376,7 +376,7 @@ async fn test_http_compress() {
376376
readiness_check_port: app_server.port().to_string(),
377377
readiness_check_path: "/healthcheck".to_string(),
378378
compression: true,
379-
..AdapterOptions::default()
379+
..Default::default()
380380
});
381381

382382
let mut svc = ServiceBuilder::new().layer(CompressionLayer::new()).service(adapter);
@@ -424,7 +424,7 @@ async fn test_http_compress_disallowed_type() {
424424
readiness_check_port: app_server.port().to_string(),
425425
readiness_check_path: "/healthcheck".to_string(),
426426
compression: true,
427-
..AdapterOptions::default()
427+
..Default::default()
428428
});
429429

430430
// // Call the adapter service with basic request
@@ -475,7 +475,7 @@ async fn test_http_compress_already_compressed() {
475475
readiness_check_port: app_server.port().to_string(),
476476
readiness_check_path: "/healthcheck".to_string(),
477477
compression: true,
478-
..AdapterOptions::default()
478+
..Default::default()
479479
});
480480

481481
let mut svc = ServiceBuilder::new().layer(CompressionLayer::new()).service(adapter);
@@ -526,7 +526,7 @@ async fn test_http_context_headers() {
526526
port: app_server.port().to_string(),
527527
readiness_check_port: app_server.port().to_string(),
528528
readiness_check_path: "/healthcheck".to_string(),
529-
..AdapterOptions::default()
529+
..Default::default()
530530
});
531531

532532
// Prepare request
@@ -576,7 +576,7 @@ async fn test_http_content_encoding_suffix() {
576576
port: app_server.port().to_string(),
577577
readiness_check_port: app_server.port().to_string(),
578578
readiness_check_path: "/healthcheck".to_string(),
579-
..AdapterOptions::default()
579+
..Default::default()
580580
});
581581

582582
// Prepare request
@@ -639,7 +639,7 @@ async fn test_http_context_multi_headers() {
639639
port: app_server.port().to_string(),
640640
readiness_check_port: app_server.port().to_string(),
641641
readiness_check_path: "/healthcheck".to_string(),
642-
..AdapterOptions::default()
642+
..Default::default()
643643
});
644644

645645
// Prepare request

0 commit comments

Comments
 (0)