Raise if the map requests a redirect. This is for example the case if `strict_slashes` are activated and an url that requires a trailing slash. The attribute `new_url` contains the absolute destination url.
| 26 | |
| 27 | |
| 28 | class RequestRedirect(HTTPException, RoutingException): |
| 29 | """Raise if the map requests a redirect. This is for example the case if |
| 30 | `strict_slashes` are activated and an url that requires a trailing slash. |
| 31 | |
| 32 | The attribute `new_url` contains the absolute destination url. |
| 33 | """ |
| 34 | |
| 35 | code = 308 |
| 36 | |
| 37 | def __init__(self, new_url: str) -> None: |
| 38 | super().__init__(new_url) |
| 39 | self.new_url = new_url |
| 40 | |
| 41 | def get_response( |
| 42 | self, |
| 43 | environ: WSGIEnvironment | Request | None = None, |
| 44 | scope: dict[str, t.Any] | None = None, |
| 45 | ) -> Response: |
| 46 | return redirect(self.new_url, self.code) |
| 47 | |
| 48 | |
| 49 | class RequestPath(RoutingException): |