1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 13:29:24 +00:00
actix-web/src/middleware
Brandur 59244b203c Let CSRF's allowed_origin() be specified as a type supporting Into<String>
A very minor addition: I'm using this middleware on specific resources,
and given a non-static string, I often have to `clone()` already to get
a string into a closure. Take this code for example:

``` rust
let server = actix_web::server::new(move || {
    let csrf_origin_graphql = csrf_origin.clone();

    ...

    .resource("/graphql", move |r| {
	r.middleware(
	    csrf::CsrfFilter::new().allowed_origin(csrf_origin_graphql.as_str()),
	);

	r.method(Method::POST).a(graphql::handlers::graphql_post);
    })
```

Letting `allowed_origin()` take an `Into<String>` instead of `&str` would
prevent a second `clone()` in the code above, and also make the code a little
nicer to read (you eliminate the `.as_str()` above). This is a pattern that
seems to be common throughout actix-web already anyway, so it should also be
fine to have here.
2018-04-21 08:41:06 -07:00
..
cors.rs Add identity service middleware 2018-04-18 19:05:24 -07:00
csrf.rs Let CSRF's allowed_origin() be specified as a type supporting Into<String> 2018-04-21 08:41:06 -07:00
defaultheaders.rs add rustfmt config 2018-04-13 16:02:01 -07:00
errhandlers.rs add rustfmt config 2018-04-13 16:02:01 -07:00
identity.rs fmt 2018-04-18 20:16:29 -07:00
logger.rs doc strings layout 2018-04-18 20:41:03 -07:00
mod.rs fmt 2018-04-18 20:16:29 -07:00
session.rs doc strings layout 2018-04-18 20:41:03 -07:00