mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 15:51:06 +01:00
apply imports_granularity fmt rule
This commit is contained in:
parent
339b81e843
commit
1561bda822
@ -1,4 +1,9 @@
|
|||||||
use std::{collections::HashSet, convert::TryFrom, convert::TryInto, fmt, rc::Rc};
|
use std::{
|
||||||
|
collections::HashSet,
|
||||||
|
convert::{TryFrom, TryInto},
|
||||||
|
fmt,
|
||||||
|
rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::RequestHead,
|
dev::RequestHead,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use actix_cors::Cors;
|
use actix_cors::Cors;
|
||||||
use actix_utils::future::ok;
|
use actix_utils::future::ok;
|
||||||
use actix_web::dev::fn_service;
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::{ServiceRequest, Transform},
|
dev::{fn_service, ServiceRequest, Transform},
|
||||||
http::{
|
http::{
|
||||||
header::{self, HeaderValue},
|
header::{self, HeaderValue},
|
||||||
Method, StatusCode,
|
Method, StatusCode,
|
||||||
|
@ -95,6 +95,4 @@ mod identity;
|
|||||||
mod identity_ext;
|
mod identity_ext;
|
||||||
mod middleware;
|
mod middleware;
|
||||||
|
|
||||||
pub use self::identity::Identity;
|
pub use self::{identity::Identity, identity_ext::IdentityExt, middleware::IdentityMiddleware};
|
||||||
pub use self::identity_ext::IdentityExt;
|
|
||||||
pub use self::middleware::IdentityMiddleware;
|
|
||||||
|
@ -60,10 +60,7 @@ mod errors;
|
|||||||
mod middleware;
|
mod middleware;
|
||||||
mod status;
|
mod status;
|
||||||
|
|
||||||
pub use self::builder::Builder;
|
pub use self::{builder::Builder, errors::Error, middleware::RateLimiter, status::Status};
|
||||||
pub use self::errors::Error;
|
|
||||||
pub use self::middleware::RateLimiter;
|
|
||||||
pub use self::status::Status;
|
|
||||||
|
|
||||||
/// Default request limit.
|
/// Default request limit.
|
||||||
pub const DEFAULT_REQUEST_LIMIT: usize = 5000;
|
pub const DEFAULT_REQUEST_LIMIT: usize = 5000;
|
||||||
|
@ -266,14 +266,14 @@ impl ProtoBufResponseBuilder for HttpResponseBuilder {
|
|||||||
value
|
value
|
||||||
.encode(&mut body)
|
.encode(&mut body)
|
||||||
.map_err(ProtoBufPayloadError::Serialize)?;
|
.map_err(ProtoBufPayloadError::Serialize)?;
|
||||||
|
|
||||||
Ok(self.body(body))
|
Ok(self.body(body))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_web::http::header;
|
use actix_web::{http::header, test::TestRequest};
|
||||||
use actix_web::test::TestRequest;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -146,9 +146,11 @@ mod session;
|
|||||||
mod session_ext;
|
mod session_ext;
|
||||||
pub mod storage;
|
pub mod storage;
|
||||||
|
|
||||||
pub use self::middleware::SessionMiddleware;
|
pub use self::{
|
||||||
pub use self::session::{Session, SessionGetError, SessionInsertError, SessionStatus};
|
middleware::SessionMiddleware,
|
||||||
pub use self::session_ext::SessionExt;
|
session::{Session, SessionGetError, SessionInsertError, SessionStatus},
|
||||||
|
session_ext::SessionExt,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod test_helpers {
|
pub mod test_helpers {
|
||||||
@ -207,9 +209,11 @@ pub mod test_helpers {
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use crate::config::{CookieContentSecurity, PersistentSession, TtlExtensionPolicy};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
storage::SessionStore, test_helpers::key, Session, SessionExt, SessionMiddleware,
|
config::{CookieContentSecurity, PersistentSession, TtlExtensionPolicy},
|
||||||
|
storage::SessionStore,
|
||||||
|
test_helpers::key,
|
||||||
|
Session, SessionExt, SessionMiddleware,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) async fn basic_workflow<F, Store>(
|
pub(super) async fn basic_workflow<F, Store>(
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
mod interface;
|
mod interface;
|
||||||
mod session_key;
|
mod session_key;
|
||||||
|
|
||||||
pub use self::interface::{LoadError, SaveError, SessionStore, UpdateError};
|
pub use self::{
|
||||||
pub use self::session_key::SessionKey;
|
interface::{LoadError, SaveError, SessionStore, UpdateError},
|
||||||
|
session_key::SessionKey,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "cookie-session")]
|
#[cfg(feature = "cookie-session")]
|
||||||
mod cookie;
|
mod cookie;
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
use std::collections::HashMap;
|
use std::{collections::HashMap, convert::TryInto};
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
use actix_session::storage::{LoadError, SaveError, SessionKey, SessionStore, UpdateError};
|
use actix_session::{
|
||||||
use actix_session::{Session, SessionMiddleware};
|
storage::{LoadError, SaveError, SessionKey, SessionStore, UpdateError},
|
||||||
use actix_web::body::MessageBody;
|
Session, SessionMiddleware,
|
||||||
use actix_web::http::StatusCode;
|
};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
|
body::MessageBody,
|
||||||
cookie::{time::Duration, Key},
|
cookie::{time::Duration, Key},
|
||||||
dev::Service,
|
dev::Service,
|
||||||
|
http::StatusCode,
|
||||||
test, web, App, Responder,
|
test, web, App, Responder,
|
||||||
};
|
};
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
|
@ -89,11 +89,13 @@ mod error;
|
|||||||
mod parse;
|
mod parse;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
||||||
pub use self::error::Error;
|
pub use self::{
|
||||||
pub use self::parse::Parse;
|
error::Error,
|
||||||
pub use self::settings::{
|
parse::Parse,
|
||||||
|
settings::{
|
||||||
ActixSettings, Address, Backlog, KeepAlive, MaxConnectionRate, MaxConnections, Mode,
|
ActixSettings, Address, Backlog, KeepAlive, MaxConnectionRate, MaxConnections, Mode,
|
||||||
NumWorkers, Timeout, Tls,
|
NumWorkers, Timeout, Tls,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Convenience type alias for `Result<T, AtError>`.
|
/// Convenience type alias for `Result<T, AtError>`.
|
||||||
|
@ -10,15 +10,11 @@ mod num_workers;
|
|||||||
mod timeout;
|
mod timeout;
|
||||||
mod tls;
|
mod tls;
|
||||||
|
|
||||||
pub use self::address::Address;
|
pub use self::{
|
||||||
pub use self::backlog::Backlog;
|
address::Address, backlog::Backlog, keep_alive::KeepAlive,
|
||||||
pub use self::keep_alive::KeepAlive;
|
max_connection_rate::MaxConnectionRate, max_connections::MaxConnections, mode::Mode,
|
||||||
pub use self::max_connection_rate::MaxConnectionRate;
|
num_workers::NumWorkers, timeout::Timeout, tls::Tls,
|
||||||
pub use self::max_connections::MaxConnections;
|
};
|
||||||
pub use self::mode::Mode;
|
|
||||||
pub use self::num_workers::NumWorkers;
|
|
||||||
pub use self::timeout::Timeout;
|
|
||||||
pub use self::tls::Tls;
|
|
||||||
|
|
||||||
/// Settings types for Actix Web.
|
/// Settings types for Actix Web.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use actix_web::dev::ServiceRequest;
|
use actix_web::{dev::ServiceRequest, middleware, web, App, Error, HttpServer};
|
||||||
use actix_web::{middleware, web, App, Error, HttpServer};
|
use actix_web_httpauth::{extractors::basic::BasicAuth, middleware::HttpAuthentication};
|
||||||
use actix_web_httpauth::extractors::basic::BasicAuth;
|
|
||||||
use actix_web_httpauth::middleware::HttpAuthentication;
|
|
||||||
|
|
||||||
async fn validator(
|
async fn validator(
|
||||||
req: ServiceRequest,
|
req: ServiceRequest,
|
||||||
|
@ -5,5 +5,4 @@ pub mod bearer;
|
|||||||
mod config;
|
mod config;
|
||||||
mod errors;
|
mod errors;
|
||||||
|
|
||||||
pub use self::config::AuthExtractorConfig;
|
pub use self::{config::AuthExtractorConfig, errors::AuthenticationError};
|
||||||
pub use self::errors::AuthenticationError;
|
|
||||||
|
@ -4,6 +4,8 @@ mod errors;
|
|||||||
mod header;
|
mod header;
|
||||||
mod scheme;
|
mod scheme;
|
||||||
|
|
||||||
pub use self::errors::ParseError;
|
pub use self::{
|
||||||
pub use self::header::Authorization;
|
errors::ParseError,
|
||||||
pub use self::scheme::{basic::Basic, bearer::Bearer, Scheme};
|
header::Authorization,
|
||||||
|
scheme::{basic::Basic, bearer::Bearer, Scheme},
|
||||||
|
};
|
||||||
|
@ -5,8 +5,7 @@ use actix_web::{
|
|||||||
web::{BufMut, Bytes, BytesMut},
|
web::{BufMut, Bytes, BytesMut},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::super::Challenge;
|
use super::{super::Challenge, BearerBuilder, Error};
|
||||||
use super::{BearerBuilder, Error};
|
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
|
|
||||||
/// Challenge for [`WWW-Authenticate`] header with HTTP Bearer auth scheme, described in [RFC 6750].
|
/// Challenge for [`WWW-Authenticate`] header with HTTP Bearer auth scheme, described in [RFC 6750].
|
||||||
|
@ -4,9 +4,7 @@ mod builder;
|
|||||||
mod challenge;
|
mod challenge;
|
||||||
mod errors;
|
mod errors;
|
||||||
|
|
||||||
pub use self::builder::BearerBuilder;
|
pub use self::{builder::BearerBuilder, challenge::Bearer, errors::Error};
|
||||||
pub use self::challenge::Bearer;
|
|
||||||
pub use self::errors::Error;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
@ -3,5 +3,7 @@
|
|||||||
mod challenge;
|
mod challenge;
|
||||||
mod header;
|
mod header;
|
||||||
|
|
||||||
pub use self::challenge::{basic, bearer, Challenge};
|
pub use self::{
|
||||||
pub use self::header::WwwAuthenticate;
|
challenge::{basic, bearer, Challenge},
|
||||||
|
header::WwwAuthenticate,
|
||||||
|
};
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
reorder_imports = true
|
|
||||||
group_imports = "StdExternalCrate"
|
group_imports = "StdExternalCrate"
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
use_field_init_shorthand = true
|
||||||
|
Loading…
Reference in New Issue
Block a user