Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

Can a Plugin decide which Route is gonna be called? #126

@marloncarvalho

Description

@marloncarvalho

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 the version number and strategy means where this version should be found (in this case, in the Accept 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.

@Group(path: '/myPath')
@Version(version: 'v1', strategy: 'header')
class AVersion1 {

    @Route(path: 'myRoute')
    MyObject get() { ... }
}

@Group(path: '/myPath')
@Version(version: 'v2', strategy: 'header')
class AVersion2 {

    @Route(path: 'myRoute')
    MyObject get() { ... }
}

With that in mind, I should be able to decide, through a plugin, which route to call (from class AVersion1 or AVersionB). Finally, my question is: is it possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions