Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Tighten HttpAuthentication::with_fn bound from FnMut to Fn. #11

Merged
merged 2 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions examples/middleware-closure.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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()
}
6 changes: 3 additions & 3 deletions src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
impl<T, F, O> HttpAuthentication<T, F>
where
T: AuthExtractor,
F: FnMut(ServiceRequest, T) -> O,
F: Fn(ServiceRequest, T) -> O,
O: IntoFuture<Item = ServiceRequest, Error = Error>,
{
/// Construct `HttpAuthentication` middleware
Expand All @@ -50,7 +50,7 @@ where

impl<F, O> HttpAuthentication<basic::BasicAuth, F>
where
F: FnMut(ServiceRequest, basic::BasicAuth) -> O,
F: Fn(ServiceRequest, basic::BasicAuth) -> O,
O: IntoFuture<Item = ServiceRequest, Error = Error>,
{
/// Construct `HttpAuthentication` middleware for the HTTP "Basic"
Expand Down Expand Up @@ -86,7 +86,7 @@ where

impl<F, O> HttpAuthentication<bearer::BearerAuth, F>
where
F: FnMut(ServiceRequest, bearer::BearerAuth) -> O,
F: Fn(ServiceRequest, bearer::BearerAuth) -> O,
O: IntoFuture<Item = ServiceRequest, Error = Error>,
{
/// Construct `HttpAuthentication` middleware for the HTTP "Bearer"
Expand Down