-
Notifications
You must be signed in to change notification settings - Fork 42
Can a Plugin decide which Route is gonna be called? #126
Comments
I think one possibility is that you create a class annotation (say @ApiGroup('/myPath', version: 'v1', strategy: 'header')
class AVersion1 {
@Route(path: 'myRoute')
MyObject get() { ... }
}
@ApiGroup('/myPath', version: 'v2', strategy: 'header')
class AVersion2 {
@Route(path: 'myRoute')
MyObject get() { ... }
} The class should be defined something like class ApiGroup extends Group {
final String version;
final String strategy;
const ApiGroup (String urlPrefix, {this.version: 'v1', this.strategy: 'header'}) : super ('/$version/$urlPrefix');
} If you are really interested, I already have the |
Your approach is only one of two possible ways to control the API versioning. The Yesterday, I tried to create a Plugin to figure out whether it's possible or not to create a plugin like that. It turned out that Redstone doesn't allow us to have more than one route with the same path. Consider the example I gave in the first comment. In that example, Redstone only recognizes the routes defined in the class Unfortunately, I think that to achieve my goal, Redstone may have to change some internal implementation. |
Redstone uses the |
I've been playing around with Redstone for a few days and my goal is to write a Redstone based RESTful API.
To accomplish it, I would like to create a simple mechanism responsible to handle API versioning. I'm thinking about creating an annotation like
@Version(version:'v1', strategy: 'header')
where the version attribute means theversion number
andstrategy
means where this version should be found (in this case, in theAccept
header).This annotation should be used at each class annotated with
@Group
(note that each route is gonna inherit this version). In that case, it's possible to have two or more classes with the same methods, same signatures and paths but belonging to different versions. Look at the two classes below.With that in mind, I should be able to decide, through a plugin, which route to call (from class
AVersion1
orAVersionB
). Finally, my question is: is it possible?The text was updated successfully, but these errors were encountered: