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

[QUESTION] How to redirect a page on server side. #14

Open
blueowlgreenfish opened this issue Aug 15, 2022 · 4 comments
Open

[QUESTION] How to redirect a page on server side. #14

blueowlgreenfish opened this issue Aug 15, 2022 · 4 comments

Comments

@blueowlgreenfish
Copy link

I'm learning how Jotsy application works using the cutting-edge technologies such as Rust, Axum, and Tokio. Right now, Jotsy application uses redirect.html to redirect a page, but meta refresh is discouraged by World Wide Web Consortium (W3C) as described here. If the Jotsy app developer decides to stick with meta refresh, it's absolutely fine. I just want to know a different approach to handling redirection, which is to redirect a page on server side. I looked into crates such as reqwest and hyper to do this, but I can't figure this out. Any suggestions will be appreciated.

@blueowlgreenfish
Copy link
Author

oh I guess I can use ResponseError::Redirect from error.rs and axum::response::Redirect to handle server-side redirection.

@ohsayan
Copy link
Owner

ohsayan commented Aug 15, 2022

Thanks for bringing this to notice. I'll switch to using the Redirect impl

@ohsayan ohsayan reopened this Aug 15, 2022
@blueowlgreenfish
Copy link
Author

I think you should handle redirecting with Redirect and axum-flash. These two combined allow you to redirect a user to a certain page with a success/error message. Using only Html::from can display a success/error message, but it only regenerates a page and does not redirect a user. On the other hand, using only Redirect does redirect a user, but can not display a success/error message. So I think when you are switching to Redirect, you should consider using both Redirect and axum-flash to handle redirecting with a message.

@ohsayan
Copy link
Owner

ohsayan commented Jan 22, 2023

Hey @blueowlgreenfish! Jotsy is actually being rewritten entirely, to improve performance and also help other developers who want to learn building web applications using Rust. I'm currently a little bogged down with stuff @skytable, but once I'm done with them — a lot is coming to Jotsy :)

Also, thank you for your note on this :D

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