controllers does not support multiple method
MuBoori opened this issue · 6 comments
MuBoori commented
joeykilpatrick commented
#41 Adds this feature
seanpmaxwell commented
Why would you want to call the exact same method for both a post and a get?
joeykilpatrick commented
Some possible scenarios:
- You want to handle the same custom error for multiple HTTP methods.
@Get('some-deprecated-function')
@Put('some-deprecated-function')
private method(req: Request, res: Response) {
return res.status(GONE).json({ // Status code 410
message: 'This resource was removed in version 2.x.x.'
});
}
- You want to handle the same method with multiple routes.
@Get('person/:id')
@Get('id/:id/person')
private get(req: Request, res: Response) {
// ...
}
MuBoori commented
Well, I have the same logic to support a return url that can be either GET
or POST so instead of doing two methods with the same logic routing them to
the same method.
As a work around i ve done the below but it would be great if it support
that as i used to work with similar java framework that it work fine with
multiple methods for the same decrotor.
@get()
Public methodA(){
Return methodB();
}
@post()
Public methodB(){}
…On Mon, 2 Mar 2020, 02:15 Joey Kilpatrick, ***@***.***> wrote:
Some possible scenarios:
- You want to handle the same custom error for multiple HTTP methods.
@get('some-deprecated-function')
@put('some-deprecated-function')private method(req: Request, res: Response) {
return res.status(GONE).json({ // Status code 410
message: 'This resource was removed in version 2.x.x.'
});
}
- You want to handle the same method with multiple routes.
@get('person/:id')
@get('id/:id/person')private get(req: Request, res: Response) {
// ...
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#46?email_source=notifications&email_token=AAJSSKMFSTDL7UVPPN7ZQKTRFLT7TA5CNFSM4K7C7ATKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENNPEFI#issuecomment-593162773>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJSSKPKPH2OYFUCVWFH2SLRFLT7TANCNFSM4K7C7ATA>
.
seanpmaxwell commented
When I finish reviewing @joeykilpatrick 's pull request, overnight will contain this feature
seanpmaxwell commented
Merged @joeykilpatrick's pull request. Sorry for taking so long.