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

Optional route segments #101

Closed
carl-berg opened this issue Mar 6, 2020 · 8 comments · Fixed by #102
Closed

Optional route segments #101

carl-berg opened this issue Mar 6, 2020 · 8 comments · Fixed by #102

Comments

@carl-berg
Copy link
Collaborator

Would be nice to be able to insert a route segment optionally. Consider this api

[BaseLocation("api/{version}")]
public interface IUserApi
{
    [Get("user")]
    Task<UserResult> GetUser([Header("Authorization")] string bearer);
}

If version=v1 you would get api/v1/user
... but if version="", you would get api//user so it would be nice if that could be handled somehow by WebAnchor

@mattiasnordqvist
Copy link
Owner

Are we happy with just repeating execution of Replace("//", "/") until there's no "//" left, or will that break anything?

@carl-berg
Copy link
Collaborator Author

carl-berg commented Mar 6, 2020

It could potentially break something i guess if someone is actually using // on purpose in a url, but is that even valid?

@mattiasnordqvist
Copy link
Owner

my browser accepts it. Let's just make it opt-in

@mattiasnordqvist
Copy link
Owner

this issue kind of also raises the question about what should happen if a route segment value is null.

@mattiasnordqvist
Copy link
Owner

Also, about normalizing urls. We could implement a lot of stuff:
https://en.wikipedia.org/wiki/URI_normalization

@mattiasnordqvist
Copy link
Owner

There ya go!

@mattiasnordqvist
Copy link
Owner

@all-contributors please add @carl-berg for bug reports

@allcontributors
Copy link
Contributor

@mattiasnordqvist

I've put up a pull request to add @carl-berg! 🎉

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

Successfully merging a pull request may close this issue.

2 participants