File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -6,16 +6,15 @@ async fn main() -> Result<(), std::io::Error> {
66 app. at ( "/" ) . get ( |_| async move { Ok ( "Root" ) } ) ;
77
88 // Redirect hackers to YouTube.
9- app. at ( "/.env" ) . get ( Redirect :: see_other (
10- "https://www.youtube.com/watch?v=dQw4w9WgXcQ" ,
11- ) ) ;
9+ app. at ( "/.env" )
10+ . get ( Redirect :: new ( "https://www.youtube.com/watch?v=dQw4w9WgXcQ" ) ) ;
1211
1312 app. at ( "/users-page" ) . get ( |_| async move {
1413 Ok ( if signed_in ( ) {
1514 Response :: new ( StatusCode :: Ok )
1615 } else {
1716 // If the user is not signed in then lets redirect them to home page.
18- Redirect :: see_other ( "/" ) . into ( )
17+ Redirect :: new ( "/" ) . into ( )
1918 } )
2019 } ) ;
2120
Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ pub struct Redirect<T: AsRef<str>> {
2828}
2929
3030impl < T : AsRef < str > > Redirect < T > {
31- /// Creates an endpoint that represents a found redirect to `location`.
31+ /// Creates an endpoint that represents a redirect to `location`.
32+ ///
33+ /// Uses status code 302 Found.
3234 ///
3335 /// # Example
3436 ///
@@ -38,14 +40,14 @@ impl<T: AsRef<str>> Redirect<T> {
3840 /// # #[allow(dead_code)]
3941 /// async fn route_handler(request: Request<()>) -> tide::Result {
4042 /// if let Some(product_url) = next_product() {
41- /// Ok(Redirect::found (product_url).into())
43+ /// Ok(Redirect::new (product_url).into())
4244 /// } else {
4345 /// //...
4446 /// # Ok(Response::new(StatusCode::Ok)) //...
4547 /// }
4648 /// }
4749 /// ```
48- pub fn found ( location : T ) -> Self {
50+ pub fn new ( location : T ) -> Self {
4951 Self {
5052 status : StatusCode :: SeeOther ,
5153 location,
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ impl Response {
6767 /// }
6868 /// ```
6969 pub fn redirect ( location : impl AsRef < str > ) -> Self {
70- Redirect :: found ( location) . into ( )
70+ Redirect :: new ( location) . into ( )
7171 }
7272
7373 /// Returns the statuscode.
You can’t perform that action at this time.
0 commit comments