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

Is there a way to support guid in pathScan? #391

Open
mastoj opened this issue Feb 19, 2016 · 2 comments
Open

Is there a way to support guid in pathScan? #391

mastoj opened this issue Feb 19, 2016 · 2 comments

Comments

@mastoj
Copy link
Contributor

mastoj commented Feb 19, 2016

I often use guids in my url since I like to generate unique ids in a simple way. I know this might be tricky, but would it be possible to add a specifier for guid in pathScan? Without that option using routes that contain one or more guid values aren't nice or type safe.

I tried using active patterns to see what it would be and I think it way to verbose if you have a lot of urls in an application, https://gist.github.com/mastoj/b191859e2c45bd233fb0.

Another approach would be to just read the parameters as a regular string and parse it in the webpart, but that isn't that nice either.

I guess this won't be fixed unless a specifier for guid is added to the Core.Printf module, or can it be added without guid support in Core.Printf?

@ademar
Copy link
Member

ademar commented Feb 21, 2016

Usually I just treat guids as strings and parse them when necessary.

I spent a little bit of time trying to get pathScan to support parsing guids via the 't' format modifier but it does not seem trivial if at all possible.

@mastoj
Copy link
Contributor Author

mastoj commented Feb 21, 2016

I think that is the easiest at the moment, but why would you differ the behavior when having a guid or an int in a string when a guid has a specific format.

I played around with the TextWriterFormat and it seems to be possible to use %A and then specify specifically that %A should be a guid.

let fmtStr = "somepath/%s/%A"
let textFormat = Printf.TextWriterFormat<string -> Guid -> unit>(fmtStr)
printfn textFormat "stuff" (Guid.NewGuid())

Not sure it helps, or if it is possible to get something like that to work in the sscanf function. The best thing would be if there was a formatter for guid.

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

No branches or pull requests

2 participants