by meddlepal · 13y ago · 0 comments
Here is an example in Groovy using JAX-RS:
@Path("/hello")
class HelloWorld {
@GET
def sayHello() {
"Hello, world!"
}
}
Almost as clean. The braces and parens make it a bit uglier; but those are just part of the language. class Hello {
def get() {
"Hello, world!"
}
}
I would prefer to see this and then let someone have a routing config somewhere else if they want to move the /hello endpoint.I've never liked the separate routing config approach. Play Framework uses(d?) it in the 1.x branch and I always found it annoying.
Similarly old-world Servlets were done that way too. You'd put the routing information in an XML file and the container would read it at start up.