-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
axum 0.8.0-rc.1: optional query parameters #3079
Comments
Right, I could see us simply remove that That said, what were you doing before? |
The code I've put is the one running with axum 0.7. |
shouldn't it be |
I'll try. |
I've tried that, and I observe the same behavior. |
can you share a reproduction? I would expect this to work 😅 |
It's an internal application. |
oh wait, I'm using a custom deserializer. The issue can come from this. |
You're right, it's working without custom deserializer. |
At the end, I could make it work with: #[debug_handler]
async fn expand(
...
consistency: Option<Query<ConsistencyParams>>,
...
) -> Response {
#[derive(Deserialize, Debug)]
struct ConsistencyParams {
#[serde(
default,
deserialize_with = "deserialize_untagged_enum_case_insensitive"
)]
consistency: Option<Consistency>,
}
fn deserialize_untagged_enum_case_insensitive<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where
T: Deserialize<'de>,
D: Deserializer<'de>,
{
use serde::de::Error;
use serde_json::Value;
T::deserialize(Value::String(
String::deserialize(deserializer)?.to_lowercase(),
))
.map_err(Error::custom)
} |
I guess I can close this issue now, unless there's something to learn from it and to change code-wise or documentation-wise. |
What could maybe be improved: I had to use an |
why did you need the |
I think what could be improved is removing the |
yep, I think I agree with that |
Yes you're right, I can use |
I'm trying out https://github.com/tokio-rs/axum/releases/tag/axum-v0.8.0-rc.1 on some internal services, and I have an issue with the change about optional extractors: #2475
My code:
When I call the HTTP endpoint without the
consistency
query parameter, the request is rejected with:The URL is looking like this:
When I look at the description of #2475, I can read:
I can observe the last behavior described:
/project-a/reference-expansion
is accepted/project-a/reference-expansion?
is not acceptedI'm not sure about this new behavior.
A handler can define several query parameters, and maybe all of them are optional.
And it needs to be able to accept a query with:
The text was updated successfully, but these errors were encountered: