2019-07-20 00:34:59 +09:00
|
|
|
use actix_web::{middleware, web, App, HttpServer};
|
|
|
|
use actix_web_httpauth::middleware::HttpAuthentication;
|
|
|
|
|
2020-11-18 15:08:03 +00:00
|
|
|
#[actix_web::main]
|
2020-01-07 01:00:43 +09:00
|
|
|
async fn main() -> std::io::Result<()> {
|
2019-07-20 00:34:59 +09:00
|
|
|
HttpServer::new(|| {
|
2020-07-21 03:51:51 +09:00
|
|
|
let auth = HttpAuthentication::basic(|req, _credentials| async { Ok(req) });
|
2019-07-20 00:34:59 +09:00
|
|
|
App::new()
|
|
|
|
.wrap(middleware::Logger::default())
|
|
|
|
.wrap(auth)
|
2020-01-07 01:00:43 +09:00
|
|
|
.service(web::resource("/").to(|| async { "Test\r\n" }))
|
2019-07-20 00:34:59 +09:00
|
|
|
})
|
|
|
|
.bind("127.0.0.1:8080")?
|
|
|
|
.workers(1)
|
|
|
|
.run()
|
2020-01-07 01:00:43 +09:00
|
|
|
.await
|
2019-07-20 00:34:59 +09:00
|
|
|
}
|