11use crate :: {
22 extensions:: max_file_size:: MaxFileSizeBytes , middleware:: api_key:: ApiKeyLayer , routes:: router,
3- service:: LambdaService ,
43} ;
5- use axum:: { Extension , Router , extract :: DefaultBodyLimit } ;
4+ use axum:: { Extension , Router } ;
65use docbox_core:: {
76 aws:: { SqsClient , aws_config} ,
87 events:: { EventPublisherFactory , sqs:: SqsEventPublisherFactory } ,
@@ -17,17 +16,16 @@ use docbox_search::{SearchIndexFactory, SearchIndexFactoryConfig};
1716use docbox_secrets:: { SecretManager , SecretsManagerConfig } ;
1817use docbox_storage:: { StorageLayerFactory , StorageLayerFactoryConfig } ;
1918use docbox_web_scraper:: { WebsiteMetaService , WebsiteMetaServiceConfig } ;
20- use lambda_http:: { Error , run , tracing} ;
19+ use lambda_http:: { Error , run_with_streaming_response , tracing} ;
2120use std:: sync:: Arc ;
22- use tower_http:: { limit :: RequestBodyLimitLayer , trace:: TraceLayer } ;
21+ use tower_http:: trace:: TraceLayer ;
2322
2423pub mod docs;
2524mod error;
2625mod extensions;
2726mod middleware;
2827mod models;
2928mod routes;
30- mod service;
3129
3230/// The server version extracted from the Cargo.toml
3331pub const VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
@@ -46,11 +44,11 @@ async fn main() -> Result<(), Error> {
4644 // TODO: Handle
4745 . unwrap ( ) ;
4846
49- run ( app) . await
47+ run_with_streaming_response ( app) . await
5048}
5149
5250// TODO: Needs a db_cache.close_all() cleanup logic when the program exits
53- async fn app ( ) -> Result < LambdaService < Router > , Box < dyn std:: error:: Error > > {
51+ async fn app ( ) -> Result < Router , Box < dyn std:: error:: Error > > {
5452 let max_file_size_bytes = match std:: env:: var ( "DOCBOX_MAX_FILE_SIZE_BYTES" ) {
5553 Ok ( value) => value. parse :: < i32 > ( ) ?,
5654 // Default max file size in bytes (100MB)
@@ -124,8 +122,6 @@ async fn app() -> Result<LambdaService<Router>, Box<dyn std::error::Error>> {
124122 . layer ( Extension ( processing) )
125123 . layer ( Extension ( tenant_cache) )
126124 . layer ( Extension ( MaxFileSizeBytes ( max_file_size_bytes) ) )
127- . layer ( DefaultBodyLimit :: disable ( ) )
128- . layer ( RequestBodyLimitLayer :: new ( max_file_size_bytes as usize ) )
129125 . layer ( TraceLayer :: new_for_http ( ) ) ;
130126
131127 if let Some ( api_key) = api_key {
@@ -140,5 +136,5 @@ async fn app() -> Result<LambdaService<Router>, Box<dyn std::error::Error>> {
140136 #[ cfg( debug_assertions) ]
141137 let app = app. layer ( tower_http:: cors:: CorsLayer :: very_permissive ( ) ) ;
142138
143- Ok ( LambdaService { inner : app } )
139+ Ok ( app)
144140}
0 commit comments