-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow wildcards in content-type #583
Comments
Would love to see a way to suppress these warnings. |
@nickdonnelly That's not currently possible with Rust's procedural macro infrastructure. I'm hoping to add it soon. First, hopefully the |
I am quite new to rust community and want to find something to try, may I take this issue? |
I think as a first step we need to decide what exactly to do and figure out how much work / how difficult the parts are. This is what I found so far:
This may not be the easiest thing to work on for a newcomer because of the code generation aspect, but any thoughts or concerns on the above points would be greatly appreciated. |
I think this works? at least it seems to work out of the box for me... Working example code#[macro_use]
extern crate rocket;
use rocket::fs::TempFile;
type V1APIResult<T> = Result<T, rocket::response::Debug<anyhow::Error>>;
#[post("/upload", format = "*/*", data = "<file>", rank = 2)]
async fn post_upload(mut file: TempFile<'_>) -> V1APIResult<()> {
println!("Temp file is {:?}", file);
Ok(())
}
#[put("/upload", format = "*/*", data = "<file>", rank = 1)]
async fn put_upload(mut file: TempFile<'_>) -> V1APIResult<()> {
println!("Temp file is {:?}", file);
Ok(())
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/v1", routes![post_upload, put_upload])
} # Rocket.toml
[debug.limits]
file = "1Gb" Executing the following: curl -svvv \
-T ../bbb_sunflower_1080p_30fps_normal.mp4 \
-H 'Content-Type: application/mp4' \
-L http://127.0.0.1:8000/v1/upload leads to a 200:
However this doesn't seem to work with the limits config, ie having: # Rocket.toml
[debug.limits]
"application/*" = "1Gb" Executing the following: curl -svvv \
-T ../bbb_sunflower_1080p_30fps_normal.mp4 \
-H 'Content-Type: application/mp4' \
-L http://127.0.0.1:8000/v1/upload leads to:
|
Currently (Rocket version 0.4.0-dev) if you use a wildcard in content-type you will get a warning like this:
Using wildcard e.g. for images is needed as you do not know what the actual type of the image will be (png, gif, jpg etc.) and you want to handle all of them in the same route.
The text was updated successfully, but these errors were encountered: