Skip to content

Commit 5c8e50d

Browse files
committed
fix: cleaned up rocket integration
Mainly just appeasing clippy, but also refactored the example server a little to make it more consistent with the inbuilt default server.
1 parent f9ce9e0 commit 5c8e50d

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Custom Server Rocket Example
22

3-
This is an example of setting up a custom server using rocket with Perseus, with one example API route.
3+
This is an example of setting up a custom server using Rocket with Perseus, with one example API route.

examples/core/custom_server_rocket/src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ pub async fn dflt_server<
2626

2727
let addr = host.parse().expect("Invalid address provided to bind to.");
2828

29-
let mut config = rocket::Config::default();
30-
3129
let mut app = perseus_base_app(turbine, opts).await;
3230
app = app.mount("/api", routes![api::hello]);
3331

34-
config.address = addr;
35-
config.port = port;
32+
let config = rocket::Config {
33+
port,
34+
address: addr,
35+
..Default::default()
36+
};
3637
app = app.configure(config);
3738

38-
match app.launch().await {
39-
Err(e) => println!("Error lauching rocket app: {}", e),
40-
_ => (),
39+
if let Err(err) = app.launch().await {
40+
eprintln!("Error lauching Rocket app: {}.", err);
4141
}
4242
}
4343

packages/perseus-rocket/src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ where
233233
Method::Get,
234234
"/translations/<path..>",
235235
RocketHandlerWithTurbine {
236-
turbine: &turbine,
236+
turbine,
237237
perseus_route: PerseusRouteKind::Locale,
238238
},
239239
);
@@ -246,7 +246,7 @@ where
246246
Method::Get,
247247
"/<path..>",
248248
RocketHandlerWithTurbine {
249-
turbine: &turbine,
249+
turbine,
250250
perseus_route: PerseusRouteKind::IntialLoadHandler,
251251
},
252252
);
@@ -255,7 +255,7 @@ where
255255
Method::Get,
256256
"/page/<path..>",
257257
RocketHandlerWithTurbine {
258-
turbine: &turbine,
258+
turbine,
259259
perseus_route: PerseusRouteKind::SubsequentLoadHandler,
260260
},
261261
);
@@ -284,7 +284,7 @@ where
284284
Method::Get,
285285
url,
286286
RocketHandlerWithTurbine {
287-
turbine: &turbine,
287+
turbine,
288288
perseus_route: PerseusRouteKind::StaticAlias(static_path),
289289
},
290290
);
@@ -311,13 +311,14 @@ pub async fn dflt_server<M: MutableStore + 'static, T: TranslationsManager + 'st
311311

312312
let mut app = perseus_base_app(turbine, opts).await;
313313

314-
let mut config = rocket::Config::default();
315-
config.port = port;
316-
config.address = addr;
314+
let config = rocket::Config {
315+
port,
316+
address: addr,
317+
..Default::default()
318+
};
317319
app = app.configure(config);
318320

319-
match app.launch().await {
320-
Err(e) => println!("Error lauching rocket app: {}", e),
321-
_ => (),
321+
if let Err(err) = app.launch().await {
322+
eprintln!("Error lauching Rocket app: {}.", err);
322323
}
323324
}

0 commit comments

Comments
 (0)