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

Implement into Uri for TypedPath #789

Closed
norman784 opened this issue Feb 24, 2022 · 1 comment · Fixed by #790
Closed

Implement into Uri for TypedPath #789

norman784 opened this issue Feb 24, 2022 · 1 comment · Fixed by #790
Labels
A-axum-macros C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@norman784
Copy link

Feature Request

Add ergonomic improvements to TypedPath

Motivation

It feels so off to write Redirect::temporary(MyPath.to_string().parse().unwrap()) instead of Redirect::temporary(MyPath.into_uri()).

Proposal

Add and implement a new trait IntoUri to TypedPath.

Alternatives

Maybe Into<Uri> works also just fine, the only open question is if/how can fail to generate the Uri.

@davidpdrsn davidpdrsn added A-axum-macros C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Feb 24, 2022
@davidpdrsn
Copy link
Member

Good call! I think we should implement TryFrom<MyPath> for Uri where the error type is InvalidUri.

davidpdrsn added a commit that referenced this issue Feb 24, 2022
`#[derive(TypedPath)]` will now also generate `TryFrom<_> for Uri` for
easily converting paths into URIs for use with `Redirect` and friends.

Fixes #789
davidpdrsn added a commit that referenced this issue Feb 24, 2022
`#[derive(TypedPath)]` will now also generate `TryFrom<_> for Uri` for
easily converting paths into URIs for use with `Redirect` and friends.

Fixes #789
davidpdrsn added a commit that referenced this issue Feb 28, 2022
* Easily convert typed paths into URIs

`#[derive(TypedPath)]` will now also generate `TryFrom<_> for Uri` for
easily converting paths into URIs for use with `Redirect` and friends.

Fixes #789

* Use a method on the `TypedPath` trait to convert to `Uri`

* fix doc ref

* Update changelogs
davidpdrsn added a commit that referenced this issue Mar 1, 2022
* Easily convert typed paths into URIs

`#[derive(TypedPath)]` will now also generate `TryFrom<_> for Uri` for
easily converting paths into URIs for use with `Redirect` and friends.

Fixes #789

* Use a method on the `TypedPath` trait to convert to `Uri`

* fix doc ref

* Update changelogs
davidpdrsn added a commit that referenced this issue Mar 1, 2022
* axum-macros: use fully qualified Result type (#796)

* Easily convert typed paths into URIs (#790)

* Easily convert typed paths into URIs

`#[derive(TypedPath)]` will now also generate `TryFrom<_> for Uri` for
easily converting paths into URIs for use with `Redirect` and friends.

Fixes #789

* Use a method on the `TypedPath` trait to convert to `Uri`

* fix doc ref

* Update changelogs

* Remove out of date docs

These accidentally weren't removed in #790

Co-authored-by: Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-axum-macros C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants