mirror of https://github.com/fafhrd91/actix-web
add a trybuild test to fail lowercase methods
This commit is contained in:
parent
6fe1b1e956
commit
53fd221240
|
@ -9,9 +9,11 @@ fn compile_macros() {
|
||||||
t.pass("tests/trybuild/route-ok.rs");
|
t.pass("tests/trybuild/route-ok.rs");
|
||||||
t.compile_fail("tests/trybuild/route-missing-method-fail.rs");
|
t.compile_fail("tests/trybuild/route-missing-method-fail.rs");
|
||||||
t.compile_fail("tests/trybuild/route-duplicate-method-fail.rs");
|
t.compile_fail("tests/trybuild/route-duplicate-method-fail.rs");
|
||||||
t.pass("tests/trybuild/route-custom-method.rs");
|
|
||||||
t.compile_fail("tests/trybuild/route-malformed-path-fail.rs");
|
t.compile_fail("tests/trybuild/route-malformed-path-fail.rs");
|
||||||
|
|
||||||
|
t.pass("tests/trybuild/route-custom-method.rs");
|
||||||
|
t.compile_fail("tests/trybuild/route-custom-lowercase.rs");
|
||||||
|
|
||||||
t.pass("tests/trybuild/routes-ok.rs");
|
t.pass("tests/trybuild/routes-ok.rs");
|
||||||
t.compile_fail("tests/trybuild/routes-missing-method-fail.rs");
|
t.compile_fail("tests/trybuild/routes-missing-method-fail.rs");
|
||||||
t.compile_fail("tests/trybuild/routes-missing-args-fail.rs");
|
t.compile_fail("tests/trybuild/routes-missing-args-fail.rs");
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
use actix_web_codegen::*;
|
||||||
|
use actix_web::http::Method;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
#[route("/", method = "hello")]
|
||||||
|
async fn index() -> String {
|
||||||
|
"Hello World!".to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_web::main]
|
||||||
|
async fn main() {
|
||||||
|
use actix_web::App;
|
||||||
|
|
||||||
|
let srv = actix_test::start(|| App::new().service(index));
|
||||||
|
|
||||||
|
let request = srv.request(Method::from_str("hello").unwrap(), srv.url("/"));
|
||||||
|
let response = request.send().await.unwrap();
|
||||||
|
assert!(response.status().is_success());
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
error: HTTP method must be uppercase: `hello`
|
||||||
|
--> tests/trybuild/route-custom-lowercase.rs:5:23
|
||||||
|
|
|
||||||
|
5 | #[route("/", method = "hello")]
|
||||||
|
| ^^^^^^^
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `fn() -> impl std::future::Future<Output = String> {index}: HttpServiceFactory` is not satisfied
|
||||||
|
--> tests/trybuild/route-custom-lowercase.rs:14:55
|
||||||
|
|
|
||||||
|
14 | let srv = actix_test::start(|| App::new().service(index));
|
||||||
|
| ------- ^^^^^ the trait `HttpServiceFactory` is not implemented for fn item `fn() -> impl std::future::Future<Output = String> {index}`
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
note: required by a bound in `App::<T>::service`
|
||||||
|
--> $WORKSPACE/actix-web/src/app.rs
|
||||||
|
|
|
||||||
|
| F: HttpServiceFactory + 'static,
|
||||||
|
| ^^^^^^^^^^^^^^^^^^ required by this bound in `App::<T>::service`
|
Loading…
Reference in New Issue