1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-30 18:34:36 +01:00
actix-extras/examples/middleware-closure.rs
Masaki Hara 4eeb1d9599 Tighten HttpAuthentication::with_fn bound from FnMut to Fn. (#11)
* Tighten HttpAuthentication::with_fn bound from FnMut to Fn.
* Add middleware with closure example.
2019-07-19 18:34:59 +03:00

19 lines
490 B
Rust

use actix_web::{middleware, web, App, HttpServer};
use futures::future;
use actix_web_httpauth::middleware::HttpAuthentication;
fn main() -> std::io::Result<()> {
HttpServer::new(|| {
let auth = HttpAuthentication::basic(|req, _credentials| future::ok(req));
App::new()
.wrap(middleware::Logger::default())
.wrap(auth)
.service(web::resource("/").to(|| "Test\r\n"))
})
.bind("127.0.0.1:8080")?
.workers(1)
.run()
}