Skip to content

Commit eab4968

Browse files
committed
fix compilation of serverless runtime
1 parent 2fc5972 commit eab4968

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/app_config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use serde::de::Error;
44
use serde::{Deserialize, Deserializer};
55
use std::net::{SocketAddr, ToSocketAddrs};
66

7+
#[cfg(not(feature = "lambda-web"))]
78
const DEFAULT_DATABASE_FILE: &str = "sqlpage.db";
89

910
#[derive(Debug, Deserialize)]

src/webserver/http.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use actix_web::{
1111
};
1212

1313
use actix_web::body::MessageBody;
14+
use anyhow::Context;
1415
use chrono::{DateTime, Utc};
1516
use futures_util::stream::Stream;
1617
use futures_util::StreamExt;
@@ -428,7 +429,9 @@ pub fn create_app(
428429
impl ServiceFactory<
429430
ServiceRequest,
430431
Config = (),
431-
Response = ServiceResponse<impl MessageBody>,
432+
Response = ServiceResponse<
433+
impl MessageBody<Error = impl std::fmt::Display + std::fmt::Debug>,
434+
>,
432435
Error = actix_web::Error,
433436
InitError = (),
434437
>,
@@ -460,9 +463,16 @@ pub async fn run_server(config: Config, state: AppState) -> anyhow::Result<()> {
460463

461464
#[cfg(feature = "lambda-web")]
462465
if lambda_web::is_running_on_lambda() {
463-
lambda_web::run_actix_on_lambda(factory).await?;
466+
lambda_web::run_actix_on_lambda(factory)
467+
.await
468+
.map_err(|e| anyhow::anyhow!("Unable to start the lambda: {e}"))?;
464469
return Ok(());
465470
}
466-
HttpServer::new(factory).bind(listen_on)?.run().await?;
471+
HttpServer::new(factory)
472+
.bind(listen_on)
473+
.with_context(|| "Unable to listen to the specified port")?
474+
.run()
475+
.await
476+
.with_context(|| "Unable to start the application")?;
467477
Ok(())
468478
}

0 commit comments

Comments
 (0)