routing-controllers icon indicating copy to clipboard operation
routing-controllers copied to clipboard

Can we create multiple paths for the same controller function?

Open crossdsection opened this issue 1 year ago • 7 comments

I was trying to...

@Get(`/api/v1/getdetails`)
@Get(`/api/v2/details`)
 public async getDetail(

The problem: We are trying to rename the bad API paths, without removing the old one. Is that possible, using the routing-controller package?

crossdsection avatar Feb 06 '24 13:02 crossdsection

That is an interesting use case, I never tried it myself but it should be fine in theory.

attilaorosz avatar Feb 06 '24 18:02 attilaorosz

@attilaorosz the above code failed, is there any other way to achieve that?

crossdsection avatar Feb 08 '24 04:02 crossdsection

When you say failed what do you mean? Is it crashing or not registering the routes?

attilaorosz avatar Feb 09 '24 16:02 attilaorosz

@attilaorosz Crashing.

crossdsection avatar Feb 11 '24 12:02 crossdsection

Could you setup a minimal repro repo so I can take a look?

attilaorosz avatar Feb 11 '24 14:02 attilaorosz

I would love to have a feature to use multiple paths for a controller.

@JsonController("/base/endpoint")
@JsonController("/old-base-routes/endpoint")

This would be useful to prepare our api to deprecate routes and start using the new ones before a major change.

soknifedev avatar Feb 21 '24 17:02 soknifedev

I just tested it locally and it works as expected. What kind of error do you get?

attilaorosz avatar Feb 24 '24 06:02 attilaorosz