Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

UriTemplate lists #179

Open
Vidarls opened this issue Feb 27, 2016 · 3 comments
Open

UriTemplate lists #179

Vidarls opened this issue Feb 27, 2016 · 3 comments

Comments

@Vidarls
Copy link
Contributor

Vidarls commented Feb 27, 2016

I tried to follow the example here: http://docs.freya.io/en/latest/router/examples.html#lists to have a list of parameters:

let myPath = (UriTemplate.parse "/my/{normalparam}/path/{paramlist*}")

//Retrieving the values:
let myParams = Freya.Optic.get (Route.list_ "paramlist")

Executing:

GET: /my/1/path/1,2

the value becomes:

["1,2"]

Any pointers to what I am doing wrong?

@kolektiv
Copy link
Member

It's not your fault, certainly. I had a nasty feeling as I saw this, and I think it's come down to the fix for this: #173 breaking things here. We're re-encoding the path and query, but that's causing 1,2 to become 1%2C2, which is then getting matched as a single value.

I'm going to need to think about this carefully. There's a (very, very annoying) assumption baked in to OWIN that the consumer would only want a percent-decoded path. I'll need to think about the right way to strike a balance here while still making something RFC compliant. I'm sure it's possible, but it's going to be trickier.

@Vidarls
Copy link
Contributor Author

Vidarls commented Feb 27, 2016

Ok, worked around it by handling the string parsing myself for now.

when working as intended will:

/path/{listofstuff*}

and

/path/{singlearg}

be matched as different paths with different handlers?

@kolektiv
Copy link
Member

The answer to that is "potentially"! Paths are matched in precedence order. There would be no way to distinguish, for example, between a listofstuff with one item, and a singlearg. So if the match with listofstuff was declared first, and higher precedence, you would never hit singlearg, as you would already have matched. If you reversed them, you would potentially still see different things, as singlearg would now match listofstuff in the single item case!

How problematic that is probably depends on your specific use case.

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

No branches or pull requests

2 participants