mirror of
https://github.com/actix/actix-extras.git
synced 2025-02-22 02:22:48 +01:00
docs(cors): use cargo-rdme
This commit is contained in:
parent
d55fc6d7f5
commit
0c859a96c8
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -3,35 +3,41 @@ name: bug report
|
||||
about: create a bug report
|
||||
---
|
||||
|
||||
Your issue may already be reported!
|
||||
Please search on the [actix-extras issue tracker](https://github.com/actix/actix-extras/issues) before creating one.
|
||||
Your issue may already be reported! Please search on the [actix-extras issue tracker](https://github.com/actix/actix-extras/issues) before creating one.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
<!--- If you're describing a bug, tell us what should happen -->
|
||||
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
||||
|
||||
## Current Behavior
|
||||
|
||||
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||
|
||||
## Possible Solution
|
||||
|
||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||
<!--- or ideas how to implement the addition or change -->
|
||||
|
||||
## Steps to Reproduce (for bugs)
|
||||
|
||||
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
||||
<!--- reproduce this bug. Include code to reproduce, if relevant -->
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
## Context
|
||||
|
||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
||||
|
||||
## Your Environment
|
||||
|
||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||
|
||||
* Rust Version (I.e, output of `rustc -V`):
|
||||
* Actix-* crate(s) Version:
|
||||
- Rust version (output of `rustc -V`):
|
||||
- `actix-*` crate versions:
|
||||
|
7
.github/PULL_REQUEST_TEMPLATE.md
vendored
7
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -2,12 +2,14 @@
|
||||
<!-- Please fill out the following to make our reviews easy. -->
|
||||
|
||||
## PR Type
|
||||
|
||||
<!-- What kind of change does this PR make? -->
|
||||
<!-- Bug Fix / Feature / Refactor / Code Style / Other -->
|
||||
|
||||
INSERT_PR_TYPE
|
||||
|
||||
|
||||
## PR Checklist
|
||||
|
||||
<!-- Check your PR fulfills the following items. -->
|
||||
<!-- For draft PRs check the boxes as you complete them. -->
|
||||
|
||||
@ -16,11 +18,10 @@ INSERT_PR_TYPE
|
||||
- [ ] A changelog entry has been made for the appropriate packages.
|
||||
- [ ] Format code with the nightly rustfmt (`cargo +nightly fmt`).
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
<!-- Describe the current and new behavior. -->
|
||||
<!-- Emphasize any breaking changes. -->
|
||||
|
||||
|
||||
<!-- If this PR fixes or closes an issue, reference it here. -->
|
||||
<!-- Closes #000 -->
|
||||
|
5
.prettierrc.yml
Normal file
5
.prettierrc.yml
Normal file
@ -0,0 +1,5 @@
|
||||
overrides:
|
||||
- files: "*.md"
|
||||
options:
|
||||
proseWrap: never
|
||||
printWidth: 9999
|
@ -44,7 +44,7 @@ These crates are provided by the community.
|
||||
| [actix-hash] | [][actix-hash] [](https://deps.rs/crate/actix-hash) | Hashing utilities for Actix Web. |
|
||||
| [actix-bincode] |  [](https://deps.rs/crate/actix-bincode) | Bincode payload extractor for Actix Web |
|
||||
| [sentinel-actix] |  [](https://deps.rs/crate/sentinel-actix) | General and flexible protection for Actix Web |
|
||||
| [actix-telepathy] |  [](https://deps.rs/crate/actix-telepathy) | Build distributed applications with `RemoteActors` and `RemoteMessages`. |
|
||||
| [actix-telepathy] |  [](https://deps.rs/crate/actix-telepathy) | Build distributed applications with `RemoteActors` and `RemoteMessages`. |
|
||||
|
||||
To add a crate to this list, submit a pull request.
|
||||
|
||||
|
@ -125,13 +125,11 @@
|
||||
- `CorsFactory` is removed. [#119]
|
||||
- The `impl Default` constructor is now overly-restrictive. [#119]
|
||||
- Added `Cors::permissive()` constructor that allows anything. [#119]
|
||||
- Adds methods for each property to reset to a permissive state. (`allow_any_origin`,
|
||||
`expose_any_header`, etc.) [#119]
|
||||
- Adds methods for each property to reset to a permissive state. (`allow_any_origin`, `expose_any_header`, etc.) [#119]
|
||||
- Errors are now propagated with `Transform::InitError` instead of panicking. [#119]
|
||||
- Fixes bug where allowed origin functions are not called if `allowed_origins` is All. [#119]
|
||||
- `AllOrSome` is no longer public. [#119]
|
||||
- Functions used for `allowed_origin_fn` now receive the Origin HeaderValue as the
|
||||
first parameter. [#120]
|
||||
- Functions used for `allowed_origin_fn` now receive the Origin HeaderValue as the first parameter. [#120]
|
||||
|
||||
[#114]: https://github.com/actix/actix-extras/pull/114
|
||||
[#118]: https://github.com/actix/actix-extras/pull/118
|
||||
|
@ -1,11 +1,69 @@
|
||||
# actix-cors
|
||||
|
||||
> Cross-Origin Resource Sharing (CORS) controls for Actix Web.
|
||||
<!-- prettier-ignore-start -->
|
||||
|
||||
[](https://crates.io/crates/actix-cors)
|
||||
[](https://docs.rs/actix-cors/0.6.5)
|
||||

|
||||

|
||||

|
||||
<br />
|
||||
[](https://deps.rs/crate/actix-cors/0.6.5)
|
||||
[](https://crates.io/crates/actix-cors)
|
||||
[](https://discord.gg/NWpN5mmg3x)
|
||||
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
<!-- cargo-rdme start -->
|
||||
|
||||
Cross-Origin Resource Sharing (CORS) controls for Actix Web.
|
||||
|
||||
This middleware can be applied to both applications and resources. Once built, a [`Cors`] builder can be used as an argument for Actix Web's `App::wrap()`, `Scope::wrap()`, or `Resource::wrap()` methods.
|
||||
|
||||
This CORS middleware automatically handles `OPTIONS` preflight requests.
|
||||
|
||||
## Crate Features
|
||||
|
||||
- `draft-private-network-access`: ⚠️ Unstable. Adds opt-in support for the [Private Network Access] spec extensions. This feature is unstable since it will follow breaking changes in the draft spec until it is finalized.
|
||||
|
||||
## Example
|
||||
|
||||
```rust
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{get, http, web, App, HttpRequest, HttpResponse, HttpServer};
|
||||
|
||||
#[get("/index.html")]
|
||||
async fn index(req: HttpRequest) -> &'static str {
|
||||
"<p>Hello World!</p>"
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
let cors = Cors::default()
|
||||
.allowed_origin("https://www.rust-lang.org")
|
||||
.allowed_origin_fn(|origin, _req_head| {
|
||||
origin.as_bytes().ends_with(b".rust-lang.org")
|
||||
})
|
||||
.allowed_methods(vec!["GET", "POST"])
|
||||
.allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
|
||||
.allowed_header(http::header::CONTENT_TYPE)
|
||||
.max_age(3600);
|
||||
|
||||
App::new()
|
||||
.wrap(cors)
|
||||
.service(index)
|
||||
})
|
||||
.bind(("127.0.0.1", 8080))?
|
||||
.run()
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
[Private Network Access]: https://wicg.github.io/private-network-access
|
||||
|
||||
<!-- cargo-rdme end -->
|
||||
|
||||
## Documentation & Resources
|
||||
|
||||
|
8
justfile
8
justfile
@ -1,6 +1,14 @@
|
||||
_list:
|
||||
@just --list
|
||||
|
||||
# Format workspace.
|
||||
fmt:
|
||||
npx -y prettier --write $(fd --hidden --extension=yml --extension=md)
|
||||
|
||||
# Update READMEs from crate root documentation.
|
||||
update-readmes: && fmt
|
||||
cd ./actix-cors && cargo rdme --force
|
||||
|
||||
# Document crates in workspace.
|
||||
doc:
|
||||
RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --all-features
|
||||
|
Loading…
x
Reference in New Issue
Block a user