-
|
From other frameworks, I am used to place hodlers: @Path("libraries/{id}")Then, I do @GET
@Produces(JabrefMediaType.BIBTEX)
public Response getBibtex(@PathParam("id") String id) {I did not find anything about that in https://github.com/byronka/restaurants/tree/master or in the documentation. Could you give some pointers? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
To explain the differences: Part 1: registering endpointsYour code registers an endpoint by using the "@path" annotation in one spot, and applying "@get" on a method. In Minum the equivalent, as succinctly as possible, is: And then you could see "Hi there world" when visiting Note there is no use of reflection in Minum, and no annotations required to use the framework. All code is plain Java (in case you were One of the example projects declares its endpoints here and an example of an endpoint is here Part 2: parameters in URLsOn the topic of parameters like "id" in URLs, you can specify values easier with query strings than path parameters. If you have an endpoint that takes a parameter of id, it is preferred to be An example is here where the endpoint will say "hello" to the value assigned to a query string key of "name", for example, "hello foo". It is possible to use path parameters, but it's harder. Path parameters add complexity for the (questionable) benefit of including parameters where one would (and should) expect path values, due to a (in my opinion, misguided) desire to follow the supposed needs of RESTful patterns. This is against the theme of Minum, which chooses the overall less-complex approach regardless of fashion or convention for the benefit of maintainability. I found it necessary to include this capability in Minum, though, just in order to provide an endpoint for the Acme challenge with Let's Encrypt. In any case, in order to have path parameters it is necessary to register a "partial path" and then use regular expressions to extract the values. For example, if you were using a pattern like and then the endpoint would look like this: Part 3: Content typeOne other item you bring up is specifying the And the method would look a bit like this: Part 4The difference in Minum is a consequence of its approach - using annotations like you mentioned ("@get", "@path", etc.) entail extra moving parts which complicate the effort of maintenance. I took a few shortcuts in explaining all this, so please reply for any points needing greater clarity. |
Beta Was this translation helpful? Give feedback.
To explain the differences:
Part 1: registering endpoints
Your code registers an endpoint by using the "@path" annotation in one spot, and applying "@get" on a method.
In Minum the equivalent, as succinctly as possible, is:
And then you could see "Hi there world" when visiting
localhost:8080/helloNote there is no use of reflection in Minum, and no annotations required to use the framework. All code is plain Java (in case you were
curious, it's to make stack traces and debugging clearer).
One of the example projects declares its endpoints here and an example of an endpoint is h…