Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
4dc5088f
Commit
4dc5088f
authored
Sep 07, 2017
by
Dominik Mostek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated documentation with new FallbackProvider
parent
4c53fd2b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
spring-cloud-netflix.adoc
docs/src/main/asciidoc/spring-cloud-netflix.adoc
+62
-0
No files found.
docs/src/main/asciidoc/spring-cloud-netflix.adoc
View file @
4dc5088f
...
...
@@ -1978,6 +1978,68 @@ class MyFallbackProvider implements ZuulFallbackProvider {
}
----
If
you
would
like
to
choose
the
response
based
on
the
cause
of
the
failure
use
`
FallbackProvider
`
which
will
replace
`
ZuulFallbackProvder
`
in
future
versions
.
[
source
,
java
]
----
class
MyFallbackProvider
implements
FallbackProvider
{
@
Override
public
String
getRoute
()
{
return
"*"
;
}
@
Override
public
ClientHttpResponse
fallbackResponse
(
final
Throwable
cause
)
{
if
(
cause
instanceof
HystrixTimeoutException
)
{
return
response
(
HttpStatus
.
GATEWAY_TIMEOUT
);
}
else
{
return
fallbackResponse
();
}
}
@
Override
public
ClientHttpResponse
fallbackResponse
()
{
return
response
(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
private
ClientHttpResponse
response
(
final
HttpStatus
status
)
{
return
new
ClientHttpResponse
()
{
@
Override
public
HttpStatus
getStatusCode
()
throws
IOException
{
return
status
;
}
@
Override
public
int
getRawStatusCode
()
throws
IOException
{
return
status
.
value
();
}
@
Override
public
String
getStatusText
()
throws
IOException
{
return
status
.
getReasonPhrase
();
}
@
Override
public
void
close
()
{
}
@
Override
public
InputStream
getBody
()
throws
IOException
{
return
new
ByteArrayInputStream
(
"fallback"
.
getBytes
());
}
@
Override
public
HttpHeaders
getHeaders
()
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
return
headers
;
}
};
}
}
----
[[
zuul
-
redirect
-
location
-
rewrite
]]
===
Rewriting
`
Location
`
header
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment