Created
June 14, 2019 08:31
-
-
Save ntr-808/39a9fd1f3563b3e247d47a927ddd0c72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn start() { | |
let database_url = env::var("DATABASE_URL") | |
.expect("DATABASE_URL must be set"); | |
let pool = create_pool(database_url); | |
HttpServer::new(move || { | |
let app = App::new() | |
.data(State { pool: pool.clone() }) | |
// enable logger | |
.wrap(middleware::Logger::default()); | |
let app = match env::var("DEV_CORS") { | |
Ok(_) => { | |
warn!("applying dev CORS middleware"); | |
app.wrap(Cors::default()) | |
}, | |
Err(_) => app | |
}; | |
return app | |
.service(web::resource("/login").route(web::post().to(login))) | |
.service(web::resource("/register").route(web::post().to(register))) | |
.service(web::resource("/ws/").route(web::get().to(ws_index))); | |
}) | |
.bind("127.0.0.1:40000").expect("could not bind to port") | |
.run().expect("could not start http server"); | |
} | |
error[E0308]: match arms have incompatible types | |
--> src/net.rs:169:23 | |
| | |
164 | let app = match env::var("DEV_CORS") { | |
| ___________________- | |
165 | | Ok(_) => { | |
166 | | warn!("applying dev CORS middleware"); | |
167 | | app.wrap(Cors::default()) | |
| | ------------------------- this is found to be of type `_` | |
168 | | }, | |
169 | | Err(_) => app | |
| | ^^^ expected opaque type, found struct `actix_web::app_service::AppEntry` | |
170 | | }; | |
| |_________- `match` arms have incompatible types | |
| | |
= note: expected type `actix_web::App<impl actix_service::NewService, _>` (opaque type) | |
found type `actix_web::App<impl actix_service::NewService, _>` (struct `actix_web::app_service::AppEntry`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment