-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7842070
Showing
9 changed files
with
520 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: "cargo" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: {} | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
rustup toolchain install nightly --profile minimal --component rustfmt --component clippy | ||
- uses: Swatinem/rust-cache@v2 | ||
- name: clippy | ||
run: | | ||
cargo clippy --all --all-targets --all-features -- -Dwarnings | ||
- name: rustfmt | ||
run: | | ||
cargo +nightly fmt --all -- --check | ||
check-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
rustup toolchain install stable --profile minimal | ||
- uses: Swatinem/rust-cache@v2 | ||
- name: cargo doc | ||
env: | ||
RUSTDOCFLAGS: "-D rustdoc::broken-intra-doc-links" | ||
run: | | ||
cargo doc --all-features --no-deps | ||
test-docs: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
rustup toolchain install nightly --profile minimal | ||
- uses: Swatinem/rust-cache@v2 | ||
- name: Run doc tests | ||
run: | | ||
cargo test --all-features --doc | ||
test-unit: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
rustup toolchain install stable --profile minimal | ||
- uses: Swatinem/rust-cache@v2 | ||
- name: Run unit tests | ||
run: | | ||
cargo test --lib --all-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "headers-accept" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Max Countryman <hello@maxcountryman.com>"] | ||
categories = ["network-programming", "web-programming"] | ||
description = "🤝 The missing `Accept` implementation for `headers::Header`" | ||
homepage = "https://github.com/maxcountryman/headers-accept" | ||
keywords = ["http", "headers", "accept", "headers-accept"] | ||
license = "MIT" | ||
readme = "README.md" | ||
repository = "https://github.com/maxcountryman/headers-accept" | ||
|
||
[dependencies] | ||
headers-core = "0.3.0" | ||
http = "1.1.0" | ||
mediatype = "0.19.18" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Max Countryman | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<h1 align="center"> | ||
headers-accept | ||
</h1> | ||
|
||
<p align="center"> | ||
🤝 The missing `Accept` implementation for `headers::Header` | ||
</p> | ||
|
||
<div align="center"> | ||
<a href="https://crates.io/crates/headers-accept"> | ||
<img src="https://img.shields.io/crates/v/headers-accept.svg" /> | ||
</a> | ||
<a href="https://docs.rs/headers-accept"> | ||
<img src="https://docs.rs/headers-accept/badge.svg" /> | ||
</a> | ||
<a href="https://github.com/maxcountryman/headers-accept/actions/workflows/rust.yml"> | ||
<img src="https://github.com/maxcountryman/headers-accept/actions/workflows/rust.yml/badge.svg" /> | ||
</a> | ||
</div> | ||
|
||
## 🎨 Overview | ||
|
||
This crate provides an implementation of `headers::Header` for `Accept`. | ||
|
||
While other crates exist, they either rely on stagnant crates like `mime` (`headers-accept` uses `mediatype` instead) or deviate from RFC 7231 (by imposing onerous sort logic) or both. | ||
|
||
This crate aims to solve these problems while adhereing to the spec outlined in [section 5.3.2](https://www.rfc-editor.org/rfc/rfc7231#section-5.3.2). | ||
|
||
## 📦 Install | ||
|
||
To use the crate in your project, add the following to your `Cargo.toml` file: | ||
|
||
```toml | ||
[dependencies] | ||
headers-accept = "0.1.0" | ||
``` | ||
|
||
## 🤸 Usage | ||
|
||
### Example | ||
|
||
```rust | ||
use std::str::FromStr; | ||
|
||
use headers_accept::Accept; | ||
use mediatype::MediaTypeBuf; | ||
|
||
let accept = Accept::from_str("audio/*; q=0.2, audio/basic").unwrap(); | ||
let mut media_types = accept.media_types(); | ||
assert_eq!( | ||
media_types.next(), | ||
Some(&MediaTypeBuf::from_str("audio/basic").unwrap()) | ||
); | ||
assert_eq!( | ||
media_types.next(), | ||
Some(&MediaTypeBuf::from_str("audio/*; q=0.2").unwrap()) | ||
); | ||
assert_eq!(media_types.next(), None); | ||
``` | ||
|
||
## 🦺 Safety | ||
|
||
This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust. | ||
|
||
## 👯 Contributing | ||
|
||
We appreciate all kinds of contributions, thank you! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
format_code_in_doc_comments = true | ||
format_strings = true | ||
imports_granularity = "Crate" | ||
group_imports = "StdExternalCrate" | ||
wrap_comments = true |
Oops, something went wrong.