Skip to content

Conversation

@SentryMan
Copy link
Collaborator

Now we can use one annotation to define a controller path instead of using Controller + Path

  • Updates Controller annotation to support path
  • Updates reader to get the path value from controller (Will prefer Controller annotation over Path annotation to get the path)

@SentryMan SentryMan changed the title Now can define path in Controller Now can define path in @Controller Jan 15, 2023
@rbygrave
Copy link
Contributor

rbygrave commented Jan 15, 2023

Yeah noting that there are 3 cases:

  1. Controller extends an interface that has @Path
  2. @Controller(...)
  3. @Controller @Path(...)

It's the controller extending an interface option which means we need to be careful and certainly not just say - always specify the path on the @Controller("/foo"

We probably need to make sure the javadoc is better in terms of explaining these 3 options .

@rbygrave rbygrave added this to the 1.23 milestone Jan 15, 2023
@rbygrave rbygrave merged commit a45a6ce into avaje:master Jan 15, 2023
@SentryMan
Copy link
Collaborator Author

SentryMan commented Jan 15, 2023

  1. Controller extends an interface that has @Path

didn't even know this was a thing you could do, I'll add it to the site docs.

@rbygrave
Copy link
Contributor

rbygrave commented Jan 15, 2023

Yes, create a java interface that is then shared by both the client and the server.

  • Create a module with the interface with @Path etc
  • Create a client module ... and use @Client.Import(...) to generate a client for the interface
  • Create a server module ... with a Controller that implements the interface

This is a thing that people can do with JAX-RS so really we are just copying JAX-RS with this approach.

Note that this isn't "ideal" in terms of client execution at scale without Loom Virtual threads ... but with Virtual Threads this becomes good and as a consequence we effectively will not bother using the HttpCall.

Without virtual threads people would probably look to create a client specific interface and use HttpCall (similar to Retrofit). Once we use HttpCall it's really a client specific interface at that point and not usable / implementable by the server controller.

Edit: We'd use @Client.Import(...) rather than @Client ... change the above to be more clear that we have a separate api module, client module and server module.

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

Successfully merging this pull request may close these issues.

2 participants