Skip to content

Make imports consistent. #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 2 additions & 4 deletions examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ use std::collections::HashSet;
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};

use futures::{sink::SinkExt, stream::StreamExt};

use tokio::sync::broadcast;

use axum::prelude::*;
use axum::response::Html;
use axum::ws::{ws, Message, WebSocket};
use axum::AddExtensionLayer;
use futures::{sink::SinkExt, stream::StreamExt};
use tokio::sync::broadcast;

// Our shared state
struct AppState {
Expand Down
3 changes: 2 additions & 1 deletion examples/error_handling_and_dependency_injection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#![allow(dead_code)]

use std::{net::SocketAddr, sync::Arc};

use axum::{
async_trait,
extract::{Extension, Json, UrlParams},
Expand All @@ -19,7 +21,6 @@ use axum::{
use http::StatusCode;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::{net::SocketAddr, sync::Arc};
use uuid::Uuid;

#[tokio::main]
Expand Down
3 changes: 2 additions & 1 deletion examples/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
//! cargo run --example form
//! ```

use std::net::SocketAddr;

use axum::prelude::*;
use serde::Deserialize;
use std::net::SocketAddr;

#[tokio::main]
async fn main() {
Expand Down
3 changes: 2 additions & 1 deletion examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
//! cargo run --example hello_world
//! ```

use axum::prelude::*;
use std::net::SocketAddr;

use axum::prelude::*;

#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
Expand Down
17 changes: 9 additions & 8 deletions examples/key_value_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
//! cargo run --example key_value_store
//! ```

use std::{
borrow::Cow,
collections::HashMap,
convert::Infallible,
net::SocketAddr,
sync::{Arc, RwLock},
time::Duration,
};

use axum::{
async_trait,
extract::{extractor_middleware, ContentLengthLimit, Extension, RequestParts, UrlParams},
Expand All @@ -16,14 +25,6 @@ use axum::{
};
use bytes::Bytes;
use http::StatusCode;
use std::{
borrow::Cow,
collections::HashMap,
convert::Infallible,
net::SocketAddr,
sync::{Arc, RwLock},
time::Duration,
};
use tower::{BoxError, ServiceBuilder};
use tower_http::{
add_extension::AddExtensionLayer, compression::CompressionLayer, trace::TraceLayer,
Expand Down
3 changes: 2 additions & 1 deletion examples/multipart_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
//! cargo run --example multipart_form --features=multipart
//! ```

use std::net::SocketAddr;

use axum::{
extract::{ContentLengthLimit, Multipart},
prelude::*,
};
use std::net::SocketAddr;

#[tokio::main]
async fn main() {
Expand Down
3 changes: 2 additions & 1 deletion examples/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! cargo run --example sessions
//! ```

use std::net::SocketAddr;

use async_session::{MemoryStore, Session, SessionStore as _};
use axum::{
async_trait,
Expand All @@ -15,7 +17,6 @@ use axum::{
use http::header::{HeaderMap, HeaderValue};
use http::StatusCode;
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
use uuid::Uuid;

#[tokio::main]
Expand Down
3 changes: 2 additions & 1 deletion examples/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
//! cargo run --example sse --features=headers
//! ```

use std::{convert::Infallible, net::SocketAddr, time::Duration};

use axum::{extract::TypedHeader, prelude::*, routing::nest, service::ServiceExt, sse::Event};
use futures::stream::{self, Stream};
use http::StatusCode;
use std::{convert::Infallible, net::SocketAddr, time::Duration};
use tokio_stream::StreamExt as _;
use tower_http::{services::ServeDir, trace::TraceLayer};

Expand Down
3 changes: 2 additions & 1 deletion examples/static_file_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
//! cargo run --example static_file_server
//! ```

use std::net::SocketAddr;

use axum::{prelude::*, routing::nest, service::ServiceExt};
use http::StatusCode;
use std::net::SocketAddr;
use tower_http::{services::ServeDir, trace::TraceLayer};

#[tokio::main]
Expand Down
3 changes: 2 additions & 1 deletion examples/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
//! cargo run --example templates
//! ```

use std::net::SocketAddr;

use askama::Template;
use axum::{prelude::*, response::IntoResponse};
use http::{Response, StatusCode};
use std::net::SocketAddr;

#[tokio::main]
async fn main() {
Expand Down
3 changes: 2 additions & 1 deletion examples/tls_rustls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
//! cargo run --example tls_rustls
//! ```

use std::{fs::File, io::BufReader, sync::Arc};

use axum::prelude::*;
use hyper::server::conn::Http;
use std::{fs::File, io::BufReader, sync::Arc};
use tokio::net::TcpListener;
use tokio_rustls::{
rustls::{
Expand Down
15 changes: 8 additions & 7 deletions examples/todos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
//! cargo run --example todos
//! ```

use std::{
collections::HashMap,
convert::Infallible,
net::SocketAddr,
sync::{Arc, RwLock},
time::Duration,
};

use axum::{
extract::{Extension, Json, Query, UrlParams},
prelude::*,
Expand All @@ -21,13 +29,6 @@ use axum::{
};
use http::StatusCode;
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
convert::Infallible,
net::SocketAddr,
sync::{Arc, RwLock},
time::Duration,
};
use tower::{BoxError, ServiceBuilder};
use tower_http::{add_extension::AddExtensionLayer, trace::TraceLayer};
use uuid::Uuid;
Expand Down
3 changes: 2 additions & 1 deletion examples/tokio_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
//! cargo run --example tokio_postgres
//! ```

use std::net::SocketAddr;

use axum::{extract::Extension, prelude::*, AddExtensionLayer};
use bb8::Pool;
use bb8_postgres::PostgresConnectionManager;
use http::StatusCode;
use std::net::SocketAddr;
use tokio_postgres::NoTls;

#[tokio::main]
Expand Down
15 changes: 8 additions & 7 deletions examples/unix_domain_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
//! cargo run --example unix_domain_socket
//! ```

use std::{
io,
path::PathBuf,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};

use axum::{
extract::connect_info::{self, ConnectInfo},
prelude::*,
Expand All @@ -14,13 +22,6 @@ use hyper::{
client::connect::{Connected, Connection},
server::accept::Accept,
};
use std::{
io,
path::PathBuf,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};
use tokio::net::{unix::UCred, UnixListener};
use tokio::{
io::{AsyncRead, AsyncWrite},
Expand Down
3 changes: 2 additions & 1 deletion examples/versioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! cargo run --example versioning
//! ```

use std::net::SocketAddr;

use axum::response::IntoResponse;
use axum::{
async_trait,
Expand All @@ -12,7 +14,6 @@ use axum::{
};
use http::Response;
use http::StatusCode;
use std::net::SocketAddr;

#[tokio::main]
async fn main() {
Expand Down
3 changes: 2 additions & 1 deletion examples/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//! RUST_LOG=tower_http=debug,key_value_store=trace cargo run --features=ws,headers --example websocket
//! ```

use std::net::SocketAddr;

use axum::{
extract::TypedHeader,
prelude::*,
Expand All @@ -14,7 +16,6 @@ use axum::{
ws::{ws, Message, WebSocket},
};
use http::StatusCode;
use std::net::SocketAddr;
use tower_http::{
services::ServeDir,
trace::{DefaultMakeSpan, TraceLayer},
Expand Down
3 changes: 2 additions & 1 deletion src/body.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! HTTP body utilities.

use std::{error::Error as StdError, fmt};

use bytes::Bytes;
use http_body::Body as _;
use std::{error::Error as StdError, fmt};
use tower::BoxError;

pub use hyper::body::Body;
Expand Down
5 changes: 3 additions & 2 deletions src/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use futures_util::ready;
use pin_project::pin_project;
use std::{
future::Future,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};

use futures_util::ready;
use pin_project::pin_project;
use tokio::sync::{mpsc, oneshot, OwnedSemaphorePermit, Semaphore};
use tokio_util::sync::PollSemaphore;
use tower::{Service, ServiceExt};
Expand Down
8 changes: 5 additions & 3 deletions src/extract/connect_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
//!
//! [`RoutingDsl::into_make_service_with_connect_info`]: crate::routing::RoutingDsl::into_make_service_with_connect_info

use super::{Extension, FromRequest, RequestParts};
use async_trait::async_trait;
use hyper::server::conn::AddrStream;
use std::{
convert::Infallible,
fmt,
marker::PhantomData,
net::SocketAddr,
task::{Context, Poll},
};

use async_trait::async_trait;
use hyper::server::conn::AddrStream;
use tower::Service;
use tower_http::add_extension::AddExtension;

use super::{Extension, FromRequest, RequestParts};

/// A [`MakeService`] created from a router.
///
/// See [`RoutingDsl::into_make_service_with_connect_info`] for more details.
Expand Down
14 changes: 8 additions & 6 deletions src/extract/extractor_middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
//!
//! See [`extractor_middleware`] for more details.

use super::{FromRequest, RequestParts};
use crate::{body::BoxBody, response::IntoResponse};
use bytes::Bytes;
use futures_util::{future::BoxFuture, ready};
use http::{Request, Response};
use pin_project::pin_project;
use std::{
fmt,
future::Future,
marker::PhantomData,
pin::Pin,
task::{Context, Poll},
};

use bytes::Bytes;
use futures_util::{future::BoxFuture, ready};
use http::{Request, Response};
use pin_project::pin_project;
use tower::{BoxError, Layer, Service};

use super::{FromRequest, RequestParts};
use crate::{body::BoxBody, response::IntoResponse};

/// Convert an extractor into a middleware.
///
/// If the extractor succeeds the value will be discarded and the inner service
Expand Down
16 changes: 9 additions & 7 deletions src/extract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,6 @@
//!
//! [`body::Body`]: crate::body::Body

use crate::{response::IntoResponse, util::ByteStr};
use async_trait::async_trait;
use bytes::{Buf, Bytes};
use futures_util::stream::Stream;
use http::{header, Extensions, HeaderMap, Method, Request, Response, Uri, Version};
use rejection::*;
use serde::de::DeserializeOwned;
use std::{
collections::HashMap,
convert::Infallible,
Expand All @@ -260,6 +253,15 @@ use std::{
task::{Context, Poll},
};

use async_trait::async_trait;
use bytes::{Buf, Bytes};
use futures_util::stream::Stream;
use http::{header, Extensions, HeaderMap, Method, Request, Response, Uri, Version};
use rejection::*;
use serde::de::DeserializeOwned;

use crate::{response::IntoResponse, util::ByteStr};

pub mod connect_info;
pub mod extractor_middleware;
pub mod rejection;
Expand Down
Loading