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

Proposal: annotation naming, qualifiers, bean validation #18

Open
macabrus opened this issue Dec 22, 2022 · 0 comments
Open

Proposal: annotation naming, qualifiers, bean validation #18

macabrus opened this issue Dec 22, 2022 · 0 comments

Comments

@macabrus
Copy link

macabrus commented Dec 22, 2022

Hello,
your library is amazing addition to pure programatic Javalin handlers.

I don't know how many projects depend on the API currently but would naming controllers and verbs:

@HttpController
    @Get 
    @Post
    ...

be more consistent with @WsController since protocol is specified in controller name?
Also, websocket events could be named without prefixes since repeating @Ws* is redundant (or maybe replace it with @On prefix to signalize it is an event?).
Plus, it is less noise in endpoint annotations.

Allow for custom @Qualifier annotation definitions so we can use more meaningful annotations as aliases instead of @UseConverter("Some.Very.Long.Unique.Namespaced.String") as they could get quite verbose and repetitive for multiple controller arguments. I kinda like writing annotations in the way natural speech would flow and I personally think it's more readable e.g.:

@Qualifier
@Target({ FIELD, PARAMETER, METHOD })
@Retention(RUNTIME)
public @interface Principal {}
@HttpGet(route = "{id}")
public User getUser(@Principal ImmutableUser u, @FromPath @Named("id") UUID id) {
    System.out.println(u); // This is currently null :(
    System.out.println(id);
    return null;
}

Allow for @Valid annotation from jakarta's spec so we could enforce validation before. And in the same manner as registering custom injector for DI library, allow for configuring custom validator bean implementation (e.g. Hibernate Validator)

@Valid @FromBody Message dto

I'd like to point out that with few more features like these, Javalin, this MVC library, Immutables.org & Guice have a potential to become a deadly combo for REST APIs. Almost like spring, but 10x faster, smaller & less boilerplate 😅

I'd like to hear your thoughts on this.

Thanks in advance

@macabrus macabrus changed the title Proposal: Proposal: annotation naming Dec 22, 2022
@macabrus macabrus changed the title Proposal: annotation naming Proposal: annotation naming, qualifiers, bean validation Dec 24, 2022
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