MCPcopy Create free account
hub / github.com/actix/examples / main

Function main

json/json/src/main.rs:32–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30
31#[actix_web::main]
32async fn main() -> std::io::Result<()> {
33 env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
34
35 log::info!("starting HTTP server at http://localhost:8080");
36
37 HttpServer::new(|| {
38 App::new()
39 // enable logger
40 .wrap(middleware::Logger::default())
41 .app_data(web::JsonConfig::default().limit(4096)) // <- limit size of the payload (global configuration)
42 .service(web::resource("/extractor").route(web::post().to(index)))
43 .service(
44 web::resource("/extractor2")
45 .app_data(web::JsonConfig::default().limit(1024)) // <- limit size of the payload (resource level)
46 .route(web::post().to(extract_item)),
47 )
48 .service(web::resource("/manual").route(web::post().to(index_manual)))
49 .service(web::resource("/").route(web::post().to(index)))
50 })
51 .bind(("127.0.0.1", 8080))?
52 .run()
53 .await
54}
55
56#[cfg(test)]
57mod tests {

Callers

nothing calls this directly

Calls 2

postFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected