Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declarative endpoint name prefixes #31

Open
rnett opened this issue Oct 24, 2021 · 0 comments
Open

Declarative endpoint name prefixes #31

rnett opened this issue Oct 24, 2021 · 0 comments

Comments

@rnett
Copy link
Owner

rnett commented Oct 24, 2021

APIs are usually hierarchically structured, for ease of use. This is poorly supported in Krosstalk, you would have to explicitly add the endpoint prefix for every method in an KrosstalkEndpoint annotation.

Idea: Annotation for classes, objects, and files(?) (and eventually namespaces) that adds a prefix to Krosstalk endpoints within them. After the krosstalk prefix? Would need to restructure KrosstalkEndpoint to not include the prefix. The class one needs to apply to the companion object as well.

This gives something like:

@KrosstalkPrefix("item")
@Serializable
data class Item(val id: String){

    @KrosstalkMethod
    @KrosstalkEndpoint("description", GET)
    suspend fun getDescription(): String

    companion object {
        @KrosstalkMethod
        @KrosstalkEndpoint(method=POST)
        suspend fun create(id: String, description: String): Item
    }
}

I'd like a way to make the description point /item/$id/description, perhaps @KrosstalkPrefix on classes could include serialization mapping, and maybe for fields if they are all constructor params?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant