forked from actix/actix-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide attribute macro for multiple HTTP methods (actix#1674)
Co-authored-by: Rob Ede <[email protected]>
- Loading branch information
Showing
15 changed files
with
263 additions
and
4 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
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
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
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
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
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
15 changes: 15 additions & 0 deletions
15
actix-web-codegen/tests/trybuild/route-duplicate-method-fail.rs
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,15 @@ | ||
use actix_web::*; | ||
|
||
#[route("/", method="GET", method="GET")] | ||
async fn index() -> impl Responder { | ||
HttpResponse::Ok() | ||
} | ||
|
||
#[actix_web::main] | ||
async fn main() { | ||
let srv = test::start(|| App::new().service(index)); | ||
|
||
let request = srv.get("/"); | ||
let response = request.send().await.unwrap(); | ||
assert!(response.status().is_success()); | ||
} |
11 changes: 11 additions & 0 deletions
11
actix-web-codegen/tests/trybuild/route-duplicate-method-fail.stderr
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,11 @@ | ||
error: HTTP Method defined more than once: `GET` | ||
--> $DIR/route-duplicate-method-fail.rs:3:35 | ||
| | ||
3 | #[route("/", method="GET", method="GET")] | ||
| ^^^^^ | ||
|
||
error[E0425]: cannot find value `index` in this scope | ||
--> $DIR/route-duplicate-method-fail.rs:10:49 | ||
| | ||
10 | let srv = test::start(|| App::new().service(index)); | ||
| ^^^^^ not found in this scope |
15 changes: 15 additions & 0 deletions
15
actix-web-codegen/tests/trybuild/route-missing-method-fail-msrv.rs
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,15 @@ | ||
use actix_web::*; | ||
|
||
#[route("/")] | ||
async fn index() -> impl Responder { | ||
HttpResponse::Ok() | ||
} | ||
|
||
#[actix_web::main] | ||
async fn main() { | ||
let srv = test::start(|| App::new().service(index)); | ||
|
||
let request = srv.get("/"); | ||
let response = request.send().await.unwrap(); | ||
assert!(response.status().is_success()); | ||
} |
11 changes: 11 additions & 0 deletions
11
actix-web-codegen/tests/trybuild/route-missing-method-fail-msrv.stderr
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,11 @@ | ||
error: The #[route(..)] macro requires at least one `method` attribute | ||
--> $DIR/route-missing-method-fail-msrv.rs:3:1 | ||
| | ||
3 | #[route("/")] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error[E0425]: cannot find value `index` in this scope | ||
--> $DIR/route-missing-method-fail-msrv.rs:10:49 | ||
| | ||
10 | let srv = test::start(|| App::new().service(index)); | ||
| ^^^^^ not found in this scope |
15 changes: 15 additions & 0 deletions
15
actix-web-codegen/tests/trybuild/route-missing-method-fail.rs
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,15 @@ | ||
use actix_web::*; | ||
|
||
#[route("/")] | ||
async fn index() -> impl Responder { | ||
HttpResponse::Ok() | ||
} | ||
|
||
#[actix_web::main] | ||
async fn main() { | ||
let srv = test::start(|| App::new().service(index)); | ||
|
||
let request = srv.get("/"); | ||
let response = request.send().await.unwrap(); | ||
assert!(response.status().is_success()); | ||
} |
13 changes: 13 additions & 0 deletions
13
actix-web-codegen/tests/trybuild/route-missing-method-fail.stderr
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,13 @@ | ||
error: The #[route(..)] macro requires at least one `method` attribute | ||
--> $DIR/route-missing-method-fail.rs:3:1 | ||
| | ||
3 | #[route("/")] | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0425]: cannot find value `index` in this scope | ||
--> $DIR/route-missing-method-fail.rs:10:49 | ||
| | ||
10 | let srv = test::start(|| App::new().service(index)); | ||
| ^^^^^ not found in this scope |
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,15 @@ | ||
use actix_web::*; | ||
|
||
#[route("/", method="GET", method="HEAD")] | ||
async fn index() -> impl Responder { | ||
HttpResponse::Ok() | ||
} | ||
|
||
#[actix_web::main] | ||
async fn main() { | ||
let srv = test::start(|| App::new().service(index)); | ||
|
||
let request = srv.get("/"); | ||
let response = request.send().await.unwrap(); | ||
assert!(response.status().is_success()); | ||
} |
Oops, something went wrong.