mirror of https://github.com/fafhrd91/actix-web
added docs, tests and updates to changes.md
This commit is contained in:
parent
63d49febea
commit
d358919902
|
@ -1,6 +1,7 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2022-xx-xx
|
## Unreleased - 2022-xx-xx
|
||||||
|
- Add support for Custom Methods with `#[route]` macro. [#2969]
|
||||||
|
|
||||||
|
|
||||||
## 4.1.0 - 2022-09-11
|
## 4.1.0 - 2022-09-11
|
||||||
|
|
|
@ -105,7 +105,7 @@ mod route;
|
||||||
/// ```
|
/// ```
|
||||||
/// # use actix_web::HttpResponse;
|
/// # use actix_web::HttpResponse;
|
||||||
/// # use actix_web_codegen::route;
|
/// # use actix_web_codegen::route;
|
||||||
/// #[route("/test", method = "GET", method = "HEAD")]
|
/// #[route("/test", method = "GET", method = "HEAD", method = "CUSTOM")]
|
||||||
/// async fn example() -> HttpResponse {
|
/// async fn example() -> HttpResponse {
|
||||||
/// HttpResponse::Ok().finish()
|
/// HttpResponse::Ok().finish()
|
||||||
/// }
|
/// }
|
||||||
|
|
|
@ -86,7 +86,13 @@ async fn get_param_test(_: web::Path<String>) -> impl Responder {
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[route("/multi", method = "GET", method = "POST", method = "HEAD")]
|
#[route(
|
||||||
|
"/multi",
|
||||||
|
method = "GET",
|
||||||
|
method = "POST",
|
||||||
|
method = "HEAD",
|
||||||
|
method = "CREATE"
|
||||||
|
)]
|
||||||
async fn route_test() -> impl Responder {
|
async fn route_test() -> impl Responder {
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
- Add rudimentary redirection service at `web::redirect()` / `web::Redirect`. [#1961]
|
- Add rudimentary redirection service at `web::redirect()` / `web::Redirect`. [#1961]
|
||||||
- Add `guard::Acceptable` for matching against `Accept` header mime types. [#2265]
|
- Add `guard::Acceptable` for matching against `Accept` header mime types. [#2265]
|
||||||
- Add fallible versions of test helpers: `try_call_service`, `try_call_and_read_body_json`, `try_read_body`, and `try_read_body_json`. [#2961]
|
- Add fallible versions of test helpers: `try_call_service`, `try_call_and_read_body_json`, `try_read_body`, and `try_read_body_json`. [#2961]
|
||||||
|
- Add `guard::Custom()` for handling `#[route]` macro with custom Methods. . [#2969]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Add `Allow` header to `Resource`'s default responses when no routes are matched. [#2949]
|
- Add `Allow` header to `Resource`'s default responses when no routes are matched. [#2949]
|
||||||
|
|
|
@ -339,6 +339,16 @@ method_guard!(Connect, CONNECT);
|
||||||
method_guard!(Patch, PATCH);
|
method_guard!(Patch, PATCH);
|
||||||
method_guard!(Trace, TRACE);
|
method_guard!(Trace, TRACE);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
#[doc = "The route in this example will respond to all uppercase ASCII requests."]
|
||||||
|
/// ```
|
||||||
|
/// use actix_web::{guard, web, HttpResponse};
|
||||||
|
///
|
||||||
|
/// web::route()
|
||||||
|
#[doc = " .guard(guard::Custom(\"HELLO\"))"]
|
||||||
|
/// .to(|| HttpResponse::Ok());
|
||||||
|
/// ```
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn Custom(custom_method: &str) -> impl Guard {
|
pub fn Custom(custom_method: &str) -> impl Guard {
|
||||||
MethodGuard(HttpMethod::from_bytes(custom_method.as_bytes()).unwrap())
|
MethodGuard(HttpMethod::from_bytes(custom_method.as_bytes()).unwrap())
|
||||||
|
|
Loading…
Reference in New Issue