seanpmaxwell/overnight

controllers does not support multiple method

Closed this issue · 6 comments

If I tried to make route to work on both Post and Get. It does not work either I get @post or @get to work in one time.

@post()
@get()
public async method(req: Reqest, res: Response) {
}

#41 Adds this feature

Why would you want to call the exact same method for both a post and a get?

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) {
    // ...
}

When I finish reviewing @joeykilpatrick 's pull request, overnight will contain this feature

Merged @joeykilpatrick's pull request. Sorry for taking so long.