Skip to content
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

Investigate "query parameter" routing #10

Open
CathalMullan opened this issue Aug 2, 2024 · 0 comments
Open

Investigate "query parameter" routing #10

CathalMullan opened this issue Aug 2, 2024 · 0 comments

Comments

@CathalMullan
Copy link
Contributor

CathalMullan commented Aug 2, 2024

See: OAI/OpenAPI-Specification#1502
See: https://github.com/opencontainers/distribution-spec/blob/main/spec.md#api

Obvious approach would be something like:

  • list?n=<integer>&last=<tagname>
  • list?<n>&<last>

Need to figure out how to handle 'array' style query parameters, e.g. created by serde_qs.

address[postcode]=12345
address[city]=Carrot+City
user_ids[0]=1
user_ids[1]=2
user_ids[2]=3
user_ids[3]=4
user_ids[]=1
user_ids[]=2
user_ids[]=3
user_ids[]=4

Do we want to be strict, and disallow and other parameters by default? Should that be a config option? Maybe some syntax for "catch all"? Maybe the default should be strict, disallow other headers. Likely cause issues with some workflows.

More interested in how this works at the router level.
Do we need a matches_request function, that takes a http crate request?

Are we going to need to write a query string parser...

Any prior art in the Rust router space, or other frameworks?

Should this wait until after we handle percent-encoding?

If we can't come up with a satisfying solution, we could just allow dynamic request constraints, e.g. passing in a ref to a http request, gaining access to raw query string.

Need to verify how duplicate query parameters should be handled.

Potential Syntax

# Simple
?name={name} -> fn(&str) # only allow 1 occurance
?name={name:*} -> fn(&[str]) # allow any number of occurances

# Empty Brackets
?names[]={names:*} -> fn(&[str]) # allow any number of occurances

# Brackets
?names[*]={names} -> fn (&[(&str, &str)]) # matches any list of headers?

I like the 'one occurance' or 'many occurances' approach.
Whether it's worthwhile to even attempt to handle this case.

See this PHP example:

user[name]=Bob+Smith&user[age]=47&user[sex]=M&user[dob]=5/12/1956&pastimes[0]=golf&pastimes[1]=opera&pastimes[2]=poker&pastimes[3]=rap&children[bobby][age]=12&children[bobby][sex]=M&children[sally][age]=8&children[sally][sex]=F&flags_0=CEO

Maybe we could handle 1 level of arrays, but nested...

Is the answer actually allowing parameters on both the key AND value parts of a header?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant