Rocket
Rocket copied to clipboard
Do not warn about unknown mime types
In several use cases, I use non-standard mime types. In particular, I've used application/x-7z-compressed
to accept a 7z archive and application/vnd.move+json
to distinguish between POST route that moves a resource and another one that creates a resource.
Because of this I always get compiler warnings about non-existing mime types such as:
warning: 'application/vnd.move+json' is not a known media type
Therefore I suggest that mime types with x-
and vnd.
prefix should be ignored by this warning.
There are other, standard media types that also warn. For example, I'm using application/merge-patch+json
for my app and I'm getting these too.
@sazzer If there's a standardized and registered media type that Rocket is unaware of, please open a PR to add it to the list of known media types.
For posterity: there is no nice mechanism, as of yet, to request that warnings emitted from proc-macros be silenced in any fashion. Note that, on stable, we cannot emit warnings (without an error), so this issue only applies to nightly. To track upstream changes that would allow us to resolve this issue, see https://github.com/rust-lang/rust/issues/54140 and specifically my proposal at https://github.com/rust-lang/rust/issues/54140#issuecomment-802701867.
Is there no way in rocket to add mime types via configuration. See the warning, add to configuration. From a security monitoring and blocking perspective if mime type is not allowed it shouldn't be served and should be reported.
See https://github.com/SergioBenitez/Rocket/discussions/2503#discussioncomment-5447420 for some of my latest thoughts on this.