| 49 | } |
| 50 | |
| 51 | fn create_app() -> App< |
| 52 | impl ServiceFactory< |
| 53 | ServiceRequest, |
| 54 | Response = ServiceResponse<impl MessageBody>, |
| 55 | Config = (), |
| 56 | InitError = (), |
| 57 | Error = Error, |
| 58 | >, |
| 59 | > { |
| 60 | App::new() |
| 61 | .service(web::scope("/api").guard(v1::ApiGuard).service(v1::hello)) |
| 62 | .service(web::scope("/api").guard(v2::ApiGuard).service(v2::hello)) |
| 63 | // using this form of API version selection means that we need to send a Vary header so that |
| 64 | // caches won't try to serve the wrong response |
| 65 | .wrap(DefaultHeaders::new().add(("Vary", "Accept-Version"))) |
| 66 | } |
| 67 | |
| 68 | #[actix_web::main] |
| 69 | async fn main() -> std::io::Result<()> { |