{"id":29632834,"url":"https://github.com/bahlo/axum-accept","last_synced_at":"2025-07-21T13:04:30.380Z","repository":{"id":303407941,"uuid":"1015412996","full_name":"bahlo/axum-accept","owner":"bahlo","description":"Typed accept negotiation for axum.","archived":false,"fork":false,"pushed_at":"2025-07-16T19:19:48.000Z","size":67,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-17T16:08:34.298Z","etag":null,"topics":["accept","axum","header","mediatype"],"latest_commit_sha":null,"homepage":"https://docs.rs/axum-accept","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahlo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-07T13:14:55.000Z","updated_at":"2025-07-16T19:19:52.000Z","dependencies_parsed_at":"2025-07-07T13:46:28.304Z","dependency_job_id":"44991b5f-86bd-4b29-8468-669127d2cd74","html_url":"https://github.com/bahlo/axum-accept","commit_stats":null,"previous_names":["bahlo/axum-accept"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bahlo/axum-accept","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahlo%2Faxum-accept","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahlo%2Faxum-accept/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahlo%2Faxum-accept/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahlo%2Faxum-accept/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahlo","download_url":"https://codeload.github.com/bahlo/axum-accept/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahlo%2Faxum-accept/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266305287,"owners_count":23908416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accept","axum","header","mediatype"],"created_at":"2025-07-21T13:04:29.263Z","updated_at":"2025-07-21T13:04:30.368Z","avatar_url":"https://github.com/bahlo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# axum-accept\n\n[![CI](https://github.com/bahlo/axum-accept/actions/workflows/ci.yml/badge.svg)](https://github.com/bahlo/axum-accept/actions/workflows/ci.yml)\n[![crates.io](https://img.shields.io/crates/v/axum-accept.svg)](https://crates.io/crates/axum-accept)\n[![docs.rs](https://docs.rs/axum-accept/badge.svg)](https://docs.rs/axum-accept/)\n[![License](https://img.shields.io/crates/l/axum-accept)](LICENSE-APACHE)\n\nTyped accept negotiation for axum, following [RFC7231](https://www.rfc-editor.org/rfc/rfc7231).\n\n## Example\n\n```rust\nuse axum::{extract::Json, response::{IntoResponse, Response}};\nuse axum_accept::AcceptExtractor;\nuse serde_json::json;\n\n#[derive(AcceptExtractor, Default)]\nenum Accept {\n    #[accept(mediatype=\"text/plain\")]\n    TextPlain,\n    #[default]\n    #[accept(mediatype=\"application/json\")]\n    ApplicationJson,\n}\n\nasync fn my_handler(accept: Accept) -\u003e Response {\n    match accept {\n        Accept::TextPlain =\u003e \"hello world\".into_response(),\n        Accept::ApplicationJson =\u003e Json(json!({ \"content\": \"hello_world\" })).into_response(),\n    }\n}\n```\n\n## Edge cases\n\nSetting a default is recommended as it indicates behaviour more explicitly in\nyour code.\nThis is how axum-accept behaves on edge cases:\n\n| Accept    | Has default               | No default                |\n| --------- | ------------------------- | ------------------------- |\n| `\u003cempty\u003e` | Default variant           | HTTP 406 (Not Acceptable) |\n| `*/*`     | Default variant           | First variant             |\n \n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahlo%2Faxum-accept","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahlo%2Faxum-accept","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahlo%2Faxum-accept/lists"}