1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-04-13 21:34:06 +00:00

eliminate handler naming restrictions #1277

This commit is contained in:
Andrey Torsunov 2020-01-20 17:50:25 +03:00
parent 3a5b62b550
commit d1d441aeba
2 changed files with 9 additions and 3 deletions

View file

@ -195,15 +195,15 @@ impl Route {
pub struct #name;
impl actix_web::dev::HttpServiceFactory for #name {
fn register(self, config: &mut actix_web::dev::AppService) {
fn register(self, __config: &mut actix_web::dev::AppService) {
#ast
let resource = actix_web::Resource::new(#path)
let __resource = actix_web::Resource::new(#path)
.name(#resource_name)
.guard(actix_web::guard::#guard())
#(.guard(actix_web::guard::fn_guard(#extra_guards)))*
.#resource_type(#name);
actix_web::dev::HttpServiceFactory::register(resource, config)
actix_web::dev::HttpServiceFactory::register(__resource, __config)
}
}
};

View file

@ -2,6 +2,12 @@ use actix_web::{http, test, web::Path, App, HttpResponse, Responder};
use actix_web_codegen::{connect, delete, get, head, options, patch, post, put, trace};
use futures::{future, Future};
// Make sure that we can name function as 'config'
#[get("/config")]
async fn config() -> impl Responder {
HttpResponse::Ok()
}
#[get("/test")]
async fn test_handler() -> impl Responder {
HttpResponse::Ok()