This repository has been archived by the owner on Oct 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
137 additions
and
125 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
use actix_web::{middleware, web, App, HttpServer}; | ||
|
||
use futures::future; | ||
|
||
use actix_web_httpauth::middleware::HttpAuthentication; | ||
|
||
fn main() -> std::io::Result<()> { | ||
#[actix_rt::main] | ||
async fn main() -> std::io::Result<()> { | ||
HttpServer::new(|| { | ||
let auth = HttpAuthentication::basic(|req, _credentials| future::ok(req)); | ||
let auth = | ||
HttpAuthentication::basic(|req, _credentials| async { Ok(req) }); | ||
App::new() | ||
.wrap(middleware::Logger::default()) | ||
.wrap(auth) | ||
.service(web::resource("/").to(|| "Test\r\n")) | ||
.service(web::resource("/").to(|| async { "Test\r\n" })) | ||
}) | ||
.bind("127.0.0.1:8080")? | ||
.workers(1) | ||
.run() | ||
.await | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
use actix_web::dev::ServiceRequest; | ||
use actix_web::{middleware, web, App, Error, HttpServer}; | ||
|
||
use futures::future; | ||
|
||
use actix_web_httpauth::extractors::basic::BasicAuth; | ||
use actix_web_httpauth::middleware::HttpAuthentication; | ||
|
||
fn validator( | ||
async fn validator( | ||
req: ServiceRequest, | ||
_credentials: BasicAuth, | ||
) -> future::FutureResult<ServiceRequest, Error> { | ||
future::ok(req) | ||
) -> Result<ServiceRequest, Error> { | ||
Ok(req) | ||
} | ||
|
||
fn main() -> std::io::Result<()> { | ||
#[actix_rt::main] | ||
async fn main() -> std::io::Result<()> { | ||
HttpServer::new(|| { | ||
let auth = HttpAuthentication::basic(validator); | ||
App::new() | ||
.wrap(middleware::Logger::default()) | ||
.wrap(auth) | ||
.service(web::resource("/").to(|| "Test\r\n")) | ||
.service(web::resource("/").to(|| async { "Test\r\n" })) | ||
}) | ||
.bind("127.0.0.1:8080")? | ||
.workers(1) | ||
.run() | ||
.await | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.