Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tokio-rs/axum
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: axum-v0.7.0
Choose a base ref
...
head repository: tokio-rs/axum
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: axum-v0.7.1
Choose a head ref
  • 3 commits
  • 9 files changed
  • 1 contributor

Commits on Nov 27, 2023

  1. Copy the full SHA
    db344fa View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e63cc49 View commit details
  3. axum 0.7.1

    Forgot that the readme is shown on crates.io and don't want the
    paragraph about "The main branch has unpublished, breaking changes".
    davidpdrsn committed Nov 27, 2023
    Copy the full SHA
    773bb5d View commit details
4 changes: 4 additions & 0 deletions axum/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- None.

# 0.7.1 (27. November, 2023)

- **fix**: Fix readme.

# 0.7.0 (27. November, 2023)

- **breaking:** Remove deprecated `WebSocketUpgrade::max_send_queue`
2 changes: 1 addition & 1 deletion axum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "axum"
version = "0.7.0"
version = "0.7.1"
categories = ["asynchronous", "network-programming", "web-programming::http-server"]
description = "Web framework that focuses on ergonomics and modularity"
edition = "2021"
6 changes: 0 additions & 6 deletions axum/README.md
Original file line number Diff line number Diff line change
@@ -8,12 +8,6 @@

More information about this crate can be found in the [crate documentation][docs].

## 🚨 The `main` branch has unpublished, breaking changes 🚨

In preparation for `axum` 0.7 the `main` branch currently has unpublished,
breaking changes. Please see the [v0.6.x](https://github.com/tokio-rs/axum/tree/v0.6.x)
branch for the versions of `axum` published to crates.io.

## High level features

- Route requests to handlers with a macro free API.
2 changes: 2 additions & 0 deletions examples/listen-multiple-addrs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -7,4 +7,6 @@ publish = false
[dependencies]
axum = { path = "../../axum" }
hyper = { version = "1.0.0", features = ["full"] }
hyper-util = { version = "0.1", features = ["tokio", "server-auto", "http1"] }
tokio = { version = "1", features = ["full"] }
tower = { version = "0.4", features = ["util"] }
117 changes: 51 additions & 66 deletions examples/listen-multiple-addrs/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,72 +1,57 @@
//! Showcases how listening on multiple addrs is possible by
//! implementing Accept for a custom struct.
//! Showcases how listening on multiple addrs is possible.
//!
//! This may be useful in cases where the platform does not
//! listen on both IPv4 and IPv6 when the IPv6 catch-all listener is used (`::`),
//! [like older versions of Windows.](https://docs.microsoft.com/en-us/windows/win32/winsock/dual-stack-sockets)
//! Showcases how listening on multiple addrs is possible by
//! implementing Accept for a custom struct.
//!
//! This may be useful in cases where the platform does not
//! listen on both IPv4 and IPv6 when the IPv6 catch-all listener is used (`::`),
//! [like older versions of Windows.](https://docs.microsoft.com/en-us/windows/win32/winsock/dual-stack-sockets)
// TODO
fn main() {
eprint!("this example has not yet been updated to hyper 1.0");
use axum::{extract::Request, routing::get, Router};
use hyper::body::Incoming;
use hyper_util::{
rt::{TokioExecutor, TokioIo},
server,
};
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
use tokio::net::TcpListener;
use tower::Service;

#[tokio::main]
async fn main() {
let app: Router = Router::new().route("/", get(|| async { "Hello, World!" }));

let localhost_v4 = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 8080);
let listener_v4 = TcpListener::bind(&localhost_v4).await.unwrap();

let localhost_v6 = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 8080);
let listener_v6 = TcpListener::bind(&localhost_v6).await.unwrap();

// See https://github.com/tokio-rs/axum/blob/main/examples/serve-with-hyper/src/main.rs for
// more details about this setup
loop {
// Accept connections from `listener_v4` and `listener_v6` at the same time
let (socket, _remote_addr) = tokio::select! {
result = listener_v4.accept() => {
result.unwrap()
}
result = listener_v6.accept() => {
result.unwrap()
}
};

let tower_service = app.clone();

tokio::spawn(async move {
let socket = TokioIo::new(socket);

let hyper_service = hyper::service::service_fn(move |request: Request<Incoming>| {
tower_service.clone().call(request)
});

if let Err(err) = server::conn::auto::Builder::new(TokioExecutor::new())
.serve_connection_with_upgrades(socket, hyper_service)
.await
{
eprintln!("failed to serve connection: {err:#}");
}
});
}
}

// use axum::{routing::get, Router};
// use hyper::server::{accept::Accept, conn::AddrIncoming};
// use std::{
// net::{Ipv4Addr, Ipv6Addr, SocketAddr},
// pin::Pin,
// task::{Context, Poll},
// };

// #[tokio::main]
// async fn main() {
// let app = Router::new().route("/", get(|| async { "Hello, World!" }));

// let localhost_v4 = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 8080);
// let incoming_v4 = AddrIncoming::bind(&localhost_v4).unwrap();

// let localhost_v6 = SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 8080);
// let incoming_v6 = AddrIncoming::bind(&localhost_v6).unwrap();

// let combined = CombinedIncoming {
// a: incoming_v4,
// b: incoming_v6,
// };

// hyper::Server::builder(combined)
// .serve(app.into_make_service())
// .await
// .unwrap();
// }

// struct CombinedIncoming {
// a: AddrIncoming,
// b: AddrIncoming,
// }

// impl Accept for CombinedIncoming {
// type Conn = <AddrIncoming as Accept>::Conn;
// type Error = <AddrIncoming as Accept>::Error;

// fn poll_accept(
// mut self: Pin<&mut Self>,
// cx: &mut Context<'_>,
// ) -> Poll<Option<Result<Self::Conn, Self::Error>>> {
// if let Poll::Ready(Some(value)) = Pin::new(&mut self.a).poll_accept(cx) {
// return Poll::Ready(Some(value));
// }

// if let Poll::Ready(Some(value)) = Pin::new(&mut self.b).poll_accept(cx) {
// return Poll::Ready(Some(value));
// }

// Poll::Pending
// }
// }
1 change: 1 addition & 0 deletions examples/testing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ publish = false
axum = { path = "../../axum" }
http-body-util = "0.1.0"
hyper = { version = "1.0.0", features = ["full"] }
hyper-util = { version = "0.1", features = ["client", "http1", "client-legacy"] }
mime = "0.3"
serde_json = "1.0"
tokio = { version = "1.0", features = ["full"] }
Loading