File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,30 @@ 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`.
32
+ ///
33
+ /// # Example
34
+ ///
35
+ /// ```
36
+ /// # use tide::{Response, Redirect, Request, StatusCode};
37
+ /// # fn next_product() -> Option<String> { None }
38
+ /// # #[allow(dead_code)]
39
+ /// async fn route_handler(request: Request<()>) -> tide::Result {
40
+ /// if let Some(product_url) = next_product() {
41
+ /// Ok(Redirect::found(product_url).into())
42
+ /// } else {
43
+ /// //...
44
+ /// # Ok(Response::new(StatusCode::Ok)) //...
45
+ /// }
46
+ /// }
47
+ /// ```
48
+ pub fn found ( location : T ) -> Self {
49
+ Self {
50
+ status : StatusCode :: SeeOther ,
51
+ location,
52
+ }
53
+ }
54
+
31
55
/// Creates an endpoint that represents a permanent redirect to `location`.
32
56
///
33
57
///
You can’t perform that action at this time.
0 commit comments