Open gsmet opened 3 years ago
Internally in core there's the MimeMapping
class that has many of these values. Perhaps an alternative suggestion would be to expose those values as constants?
@vietj wdyt?
it could be also achieve in reactive routes integration layer, so I think the concern is that beside using in reactive routes, would it make sense to have in vertx-web itself for users not using reactive routes?
ok, @gsmet would an interface like:
@VertxGen
public interface MimeType {
String APPLICATION_JSON = "application/json";
...
}
Be enough?
Using this approach, users can still use the string notation for custom types, for example: application/json+myextension
or use the constant from the interface which avoids typpo
kind of errors.
Yes, I'm all to keep them simple strings.
@gsmet, let's start small, I'll just dump the same list we have in core but as constants for now and users are welcome to do later pull requests for missing types.
Now the trick is name things. How should we encode the constant names, for example there are:
application/json
application/vnd.ms-excel
image/svg+xml
Should we just replace all not allowed variable name characters as _
?
APPLICATION_JSON
APPLICATION_VND_MS_EXCEL
IMAGE_SVG_XML
Or have a group like the IANA
registry: http://www.iana.org/assignments/media-types/media-types.xhtml
Though inner classes/interfaces are known to cause trouble with codegen.
I would keep it simple and have an approach similar to the RESTEasy code I posted above.
Also I think having the ones listed in RESTEasy would probably be a good start. No need for all of them.
Hi,
I'm using Reactive Routes in Quarkus which relies on Vert.x Web and, as someone familiar with JAX-RS, I miss my MediaType constants.
See https://github.com/jax-rs/api/blob/master/jaxrs-api/src/main/java/javax/ws/rs/core/MediaType.java#L77 . I'm talking about the String constants specifically so that I could use them when declaring
@Route
annotations (forconsumes
andproduces
).Would it make sense to expose such a class in Vert.x Web?
Thanks!