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> {
6
6
app. at ( "/" ) . get ( |_| async move { Ok ( "Root" ) } ) ;
7
7
8
8
// 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" ) ) ;
12
11
13
12
app. at ( "/users-page" ) . get ( |_| async move {
14
13
Ok ( if signed_in ( ) {
15
14
Response :: new ( StatusCode :: Ok )
16
15
} else {
17
16
// If the user is not signed in then lets redirect them to home page.
18
- Redirect :: see_other ( "/" ) . into ( )
17
+ Redirect :: new ( "/" ) . into ( )
19
18
} )
20
19
} ) ;
21
20
Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ pub struct Redirect<T: AsRef<str>> {
28
28
}
29
29
30
30
impl < 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.
32
34
///
33
35
/// # Example
34
36
///
@@ -38,14 +40,14 @@ impl<T: AsRef<str>> Redirect<T> {
38
40
/// # #[allow(dead_code)]
39
41
/// async fn route_handler(request: Request<()>) -> tide::Result {
40
42
/// if let Some(product_url) = next_product() {
41
- /// Ok(Redirect::found (product_url).into())
43
+ /// Ok(Redirect::new (product_url).into())
42
44
/// } else {
43
45
/// //...
44
46
/// # Ok(Response::new(StatusCode::Ok)) //...
45
47
/// }
46
48
/// }
47
49
/// ```
48
- pub fn found ( location : T ) -> Self {
50
+ pub fn new ( location : T ) -> Self {
49
51
Self {
50
52
status : StatusCode :: SeeOther ,
51
53
location,
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ impl Response {
67
67
/// }
68
68
/// ```
69
69
pub fn redirect ( location : impl AsRef < str > ) -> Self {
70
- Redirect :: found ( location) . into ( )
70
+ Redirect :: new ( location) . into ( )
71
71
}
72
72
73
73
/// Returns the statuscode.
You can’t perform that action at this time.
0 commit comments