mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-26 10:27:42 +02:00
move files into module
This commit is contained in:
19
actix-web-httpauth/examples/middleware-closure.rs
Normal file
19
actix-web-httpauth/examples/middleware-closure.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use actix_web::{middleware, web, App, HttpServer};
|
||||
|
||||
use actix_web_httpauth::middleware::HttpAuthentication;
|
||||
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
let auth =
|
||||
HttpAuthentication::basic(|req, _credentials| async { Ok(req) });
|
||||
App::new()
|
||||
.wrap(middleware::Logger::default())
|
||||
.wrap(auth)
|
||||
.service(web::resource("/").to(|| async { "Test\r\n" }))
|
||||
})
|
||||
.bind("127.0.0.1:8080")?
|
||||
.workers(1)
|
||||
.run()
|
||||
.await
|
||||
}
|
Reference in New Issue
Block a user