Skip to content

Commit

Permalink
Format YAML and Markdown files with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Jul 30, 2024
1 parent b8ac43a commit 70848a5
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 38 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ jobs:
tool: taplo-cli
- name: Run Taplo
run: taplo fmt --check

prettier:
name: Prettier

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Prettier
run: sudo npm i -g prettier
- name: Run Prettier
run: prettier . --check
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches: ["main"]
pull_request:


concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
github.event.comment.body == '/fast-forward-merge'
permissions:
actions: write
contents: write
pull-requests: write
actions: write
contents: write
pull-requests: write

steps:
- name: Checkout
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches: ["main"]
pull_request:


concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ jobs:
rustup toolchain install ${{ matrix.rust }} --profile minimal
rustup default ${{ matrix.rust }}
- name: Install nightly Rust
run:
rustup toolchain install nightly --profile minimal
run: rustup toolchain install nightly --profile minimal
- name: Build
working-directory: minimal-versions
run: |
Expand Down
7 changes: 7 additions & 0 deletions .prettierrc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
arrowParens = "avoid"
printWidth = 100
proseWrap = "always"
semi = false
tabWidth = 2
trailingComma = "es5"
useTabs = true
40 changes: 33 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,95 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.0] - 2023-12-22

### Added

- Re-export `http-body-util`, `tokio` and `tower-service`.

### Changed

- Increased MSRV to v1.66.
- Updated `axum-server` to v0.6.
- Updated `http` to v1.

### Removed

- Removed `hyper` re-export.

## [0.5.2] - 2023-06-16

### Added

- Re-export `bytes`, `http`, `hyper`, `tokio-rustls` and `tokio-util`.

### Changed

- Updated `rcgen` to v0.11.

## [0.5.1] - 2023-06-13

### Added

- Re-export `axum-server`.

## [0.5.0] - 2023-06-03

### Added
- Introduced [`Protocol`](https://docs.rs/axum-server-dual-protocol/0.5.0/axum_server_dual_protocol/enum.Protocol.html).
Which can be used with [`Request::extensions()`](https://docs.rs/http/0.2.9/http/request/struct.Request.html#method.extensions)

- Introduced
[`Protocol`](https://docs.rs/axum-server-dual-protocol/0.5.0/axum_server_dual_protocol/enum.Protocol.html).
Which can be used with
[`Request::extensions()`](https://docs.rs/http/0.2.9/http/request/struct.Request.html#method.extensions)
to extract a requests protocol.

### Fixed

- Secure WebSocket handshakes are now accepted, instead of redirected to the `https` URI scheme.
- Upgrade insecure WebSocket handshakes to the `wss` instead of the `https` URI scheme.

### Changed
- Unknown URI schemes are now responded to with "400 Bad Request" instead of redirected to the `https` URI scheme.

- Unknown URI schemes are now responded to with "400 Bad Request" instead of redirected to the
`https` URI scheme.

## [0.4.0] - 2023-05-04

### Changed

- Updated `axum-server` to v0.5.
- Updated `tokio-rustls` to v0.24.

## [0.3.0] - 2022-11-26

### Added

- Implemented `from_tcp_dual_protocol()`, equivalent to
[`axum_server::from_tcp`](https://docs.rs/axum-server/0.4.4/axum_server/fn.from_tcp_rustls.html).

### Changed

- Updated `axum` to v0.6.
- Increased MSRV to v1.60.

## [0.2.0] - 2022-07-30

### Added
- Implemented `ServerExt::set_upgrade()`, an easy way to apply `UpgradeHttpLayer`
to the entire app.

- Implemented `ServerExt::set_upgrade()`, an easy way to apply `UpgradeHttpLayer` to the entire app.

### Changed

- Renamed `DualProtocolFuture` to `DualProtocolAcceptorFuture`.

## [0.1.0] - 2022-07-28

### Added

- Initial commit.

[Unreleased]: https://github.com/daxpedda/axum-server-dual-protocol/compare/v0.6.0...main
Expand Down
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@
[![Crates.io Version](https://img.shields.io/crates/v/axum-server-dual-protocol.svg)](https://crates.io/crates/axum-server-dual-protocol)
[![Live Build Status](https://img.shields.io/github/check-runs/daxpedda/axum-server-dual-protocol/main?label=CI)](https://github.com/daxpedda/axum-server-dual-protocol/actions?query=branch%3Amain)
[![Docs.rs Documentation](https://img.shields.io/docsrs/axum-server-dual-protocol?label=docs.rs)](https://docs.rs/crate/axum-server-dual-protocol)
[![Main Documentation](https://img.shields.io/github/actions/workflow/status/daxpedda/axum-server-dual-protocol/documentation.yml?branch=main&label=main%20docs
)](https://daxpedda.github.io/axum-server-dual-protocol/axum_server_dual_protocol/index.html)
[![Main Documentation](https://img.shields.io/github/actions/workflow/status/daxpedda/axum-server-dual-protocol/documentation.yml?branch=main&label=main%20docs)](https://daxpedda.github.io/axum-server-dual-protocol/axum_server_dual_protocol/index.html)

## Description

Provides utilities to host a [`axum-server`] server that
accepts the HTTP and HTTPS protocol on the same port. See
[`bind_dual_protocol()`].
Provides utilities to host a [`axum-server`] server that accepts the HTTP and HTTPS protocol on the
same port. See [`bind_dual_protocol()`].

A common use case for this is if a HTTPS server is hosted on a
non-traditional port, having no corresponding HTTP port. This can be an
issue for clients who try to connect over HTTP and get a connection reset
error. See [`ServerExt::set_upgrade()`].
A common use case for this is if a HTTPS server is hosted on a non-traditional port, having no
corresponding HTTP port. This can be an issue for clients who try to connect over HTTP and get a
connection reset error. See [`ServerExt::set_upgrade()`].

## Usage

The simplest way to start is to use [`bind_dual_protocol()`]:

```rust
let app = Router::new().route(
"/",
Expand All @@ -39,9 +37,9 @@ axum_server_dual_protocol::bind_dual_protocol(address, config)
.await?;
```

We now have a server accepting both HTTP and HTTPS requests! Now we can
automatically upgrade incoming HTTP requests to HTTPS using
[`ServerExt::set_upgrade()`] like this:
We now have a server accepting both HTTP and HTTPS requests! Now we can automatically upgrade
incoming HTTP requests to HTTPS using [`ServerExt::set_upgrade()`] like this:

```rust
use axum_server_dual_protocol::ServerExt;

Expand All @@ -52,6 +50,7 @@ axum_server_dual_protocol::bind_dual_protocol(address, config)
```

Alternatively [`UpgradeHttpLayer`] can be used:

```rust
let app = Router::new()
.route("/", routing::get(|| async { "Hello, world!" }))
Expand All @@ -62,14 +61,13 @@ let app = Router::new()

### `docsrs`

This requires Rust nightly and enhances the documentation. It must only be
used with `RUSTDOCFLAGS`, not with `RUSTFLAGS`.
This requires Rust nightly and enhances the documentation. It must only be used with `RUSTDOCFLAGS`,
not with `RUSTFLAGS`.

## MSRV

As this library heavily relies on [`axum-server`], [`axum`],
[`tower`] and [`hyper`] the MSRV depends on theirs. At the point of time
this was written the highest MSRV was [`axum`] with 1.66.
As this library heavily relies on [`axum-server`], [`axum`], [`tower`] and [`hyper`] the MSRV
depends on theirs. At the point of time this was written the highest MSRV was [`axum`] with 1.66.

## Changelog

Expand All @@ -86,20 +84,22 @@ at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the
work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.

[CHANGELOG]: https://github.com/daxpedda/axum-server-dual-protocol/blob/v0.6.0/CHANGELOG.md
[LICENSE-MIT]: https://github.com/daxpedda/axum-server-dual-protocol/blob/v0.6.0/LICENSE-MIT
[LICENSE-APACHE]: https://github.com/daxpedda/axum-server-dual-protocol/blob/v0.6.0/LICENSE-APACHE
[`axum`]: https://docs.rs/axum/0.7
[`axum-server`]: https://docs.rs/axum-server/0.6.0
[`bind_dual_protocol()`]: https://docs.rs/axum-server-dual-protocol/0.6.0/axum_server_dual_protocol/fn.bind_dual_protocol.html
[`bind_dual_protocol()`]:
https://docs.rs/axum-server-dual-protocol/0.6.0/axum_server_dual_protocol/fn.bind_dual_protocol.html
[`hyper`]: https://docs.rs/hyper/1
[`Layer`]: https://docs.rs/tower-layer/0.3/tower_layer/trait.Layer.html
[`Router`]: https://docs.rs/axum/0.7/axum/struct.Router.html
[`ServerExt::set_upgrade()`]: https://docs.rs/axum-server-dual-protocol/0.6.0/axum_server_dual_protocol/trait.ServerExt.html#tymethod.set_upgrade
[`ServerExt::set_upgrade()`]:
https://docs.rs/axum-server-dual-protocol/0.6.0/axum_server_dual_protocol/trait.ServerExt.html#tymethod.set_upgrade
[`tower`]: https://docs.rs/tower/0.4
[`UpgradeHttpLayer`]: https://docs.rs/axum-server-dual-protocol/0.6.0/axum_server_dual_protocol/struct.UpgradeHttpLayer.html
[`UpgradeHttpLayer`]:
https://docs.rs/axum-server-dual-protocol/0.6.0/axum_server_dual_protocol/struct.UpgradeHttpLayer.html

0 comments on commit 70848a5

Please sign in to comment.