Skip to content

Handling "not a known media type" #2503

Discussion options

You must be logged in to vote

Unfortunately, there's no way to dynamically add a media type to the list of known media types. The challenge is that warnings are emitted at compile-time whereas configuration can be completely interpreted at runtime. That is, using Rocket.toml is the default configuration source, but it can be completely replaced by anything at all, including over the network, a different file, etc. So reading something like Rocket.toml at compile-time will work but changes the meaning of configuration.

One idea I've had is to add a rocket::allow codegen attribute that can be used on routes to silence warnings:

#[rocket::allow(unknown_media_type)]
#[get("/.well-known/webfinger?<resource>", format = "app…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@justindthomas
Comment options

@SergioBenitez
Comment options

@justindthomas
Comment options

Answer selected by justindthomas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2469 on March 25, 2023 14:55.