You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: context/middleware.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ use Utopia::Static,
18
18
19
19
## Redirection
20
20
21
-
The {ruby Utopia::Redirection} middleware is used for redirecting requests based on patterns and status codes.
21
+
The {ruby Utopia::Redirection} middleware is used for redirecting requests based on paths.
22
22
23
23
~~~ruby
24
24
use Utopia::Redirectiondo |redirects|
@@ -30,12 +30,16 @@ use Utopia::Redirection do |redirects|
30
30
31
31
# Redirect matching path prefixes:
32
32
redirects.moved '/old/', '/new/'
33
-
34
-
# Redirect error status codes to internal error documents:
35
-
redirects.error 404, '/errors/file-not-found'
36
33
end
37
34
~~~
38
35
36
+
The {ruby Utopia::Redirection::Errors} middleware maps unhandled error responses to internal error documents. It retains the original response status and does not issue a client-visible redirect:
37
+
38
+
~~~ruby
39
+
use Utopia::Redirection::Errors,
40
+
404 => '/errors/file-not-found'
41
+
~~~
42
+
39
43
## Localization
40
44
41
45
The {ruby Utopia::Localization} middleware computes immutable localization preferences from the request path, host, and `accept-language` header. Localization-aware resource middleware, including {ruby Utopia::Static} and {ruby Utopia::Content}, resolves those preferences without invoking controllers more than once. Place the localization middleware before those resources in the middleware stack.
Copy file name to clipboardExpand all lines: guides/middleware/readme.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ use Utopia::Static,
18
18
19
19
## Redirection
20
20
21
-
The {ruby Utopia::Redirection} middleware is used for redirecting requests based on patterns and status codes.
21
+
The {ruby Utopia::Redirection} middleware is used for redirecting requests based on paths.
22
22
23
23
~~~ruby
24
24
use Utopia::Redirectiondo |redirects|
@@ -30,12 +30,16 @@ use Utopia::Redirection do |redirects|
30
30
31
31
# Redirect matching path prefixes:
32
32
redirects.moved '/old/', '/new/'
33
-
34
-
# Redirect error status codes to internal error documents:
35
-
redirects.error 404, '/errors/file-not-found'
36
33
end
37
34
~~~
38
35
36
+
The {ruby Utopia::Redirection::Errors} middleware maps unhandled error responses to internal error documents. It retains the original response status and does not issue a client-visible redirect:
37
+
38
+
~~~ruby
39
+
use Utopia::Redirection::Errors,
40
+
404 => '/errors/file-not-found'
41
+
~~~
42
+
39
43
## Localization
40
44
41
45
The {ruby Utopia::Localization} middleware computes immutable localization preferences from the request path, host, and `accept-language` header. Localization-aware resource middleware, including {ruby Utopia::Static} and {ruby Utopia::Content}, resolves those preferences without invoking controllers more than once. Place the localization middleware before those resources in the middleware stack.
0 commit comments