Compare commits

...

623 Commits
3.0.x ... main

Author SHA1 Message Date
buildmaster 2f39ba705d Bumping versions 11 months ago
JesseEstum d0f8dd4f27
Fix typo in docs (#3061) 11 months ago
Alexej Timonin beb688fd45
Proposal to clarify in the docs that request size filter acts on Content-Length header (#3085) 11 months ago
Vahid Ramezani bec2f5310b
increase code readability (#3096) 11 months ago
dependabot[bot] 70d8b2989f
Bump bucket4j.version from 8.5.0 to 8.6.0 (#3118) 11 months ago
dependabot[bot] 1e09e2f51d
Bump grpc.version from 1.58.0 to 1.59.0 (#3109) 11 months ago
dependabot[bot] a73778fefb
Bump actions/checkout from 3 to 4 (#3067) 11 months ago
Marta Medio 1a31026e98
Deprecate KeyValue configuration from Filter and extract it into a config package (#3107) 11 months ago
sgibb 56d4f52303
formatting 11 months ago
Ignacio Lozano 6b235916af
Correct the order when routes are refreshed by group (#3112) 11 months ago
buildmaster 8a33b72f5b Bumping versions 11 months ago
Ignacio Lozano 8c821197af
Correct the order when routes are refreshed by group (#3112) 11 months ago
buildmaster 6d2055ac05 Going back to snapshots 11 months ago
buildmaster fb325a5216 Update SNAPSHOT to 4.1.0-RC1 11 months ago
buildmaster 51367a8668 Bumping versions 11 months ago
sgibb 9d6ab543fd
Correctly proxy form urlencoded posts. 11 months ago
sgibb ec69691133
Formatting 11 months ago
sgibb 3db2b35c90
Implements new methods 11 months ago
sgibb 5a9b234b7d
Disables ServerMvcIntegrationTests.formUrlencodedWorks() 12 months ago
sgibb e9cfe1df35
Asserts headers are not null. 12 months ago
sgibb 0321c64c85
Makes ArgumentSupplierBeanPostProcessor bean method static 12 months ago
sgibb 76e35bbc08
Merge branch '4.0.x' 12 months ago
Gaurav Ojha 7dff7319a6
Support spring.codec.max-in-memory-size configuration for CacheRequestBodyFilter 12 months ago
sgibb 9c11a8ed8a
Adds rewriterequestparameter-factory.adoc 12 months ago
sgibb 77779ff91a
Merge branch '4.0.x' 12 months ago
Fredrich Ombico 41b212db5c
Add RewriteRequestParameter GatewayFilter factory (#3081) 12 months ago
sgibb 138a49afa0
Merge remote-tracking branch 'origin/main' 12 months ago
sgibb 9c37027706
Merge branch '4.0.x' 12 months ago
sgibb a76bf7c982
Merge branch 'filter/local-response-cache/no-cache-directive' into 4.0.x 12 months ago
sgibb 29ec0728a8
Polish gh-3047 "Correct inconsistencies in the Cache-Control..." 12 months ago
buildmaster 9fce110c42
Correct LocalResponseCache behaviour w/ "no-cache", "must-revalidate", "max-age" and "no-store" directives 12 months ago
dependabot[bot] faebdea9cd
Bump org.testcontainers:testcontainers-bom from 1.17.3 to 1.19.1 (#3087) 12 months ago
dependabot[bot] 9d664d9424
Bump org.junit-pioneer:junit-pioneer from 1.6.1 to 1.9.1 (#3090) 12 months ago
dependabot[bot] fc1e120157
Bump bucket4j.version from 8.3.0 to 8.5.0 (#3089) 12 months ago
dependabot[bot] 86d5f9fa61
Bump grpc.version from 1.47.0 to 1.58.0 (#3074) 12 months ago
dependabot[bot] 7b366d1011
Bump org.apache.maven.plugins:maven-jar-plugin from 3.2.0 to 3.3.0 (#3078) 12 months ago
dependabot[bot] b9ef914ae5
Bump actions/checkout from 3 to 4 (#3073) 12 months ago
dependabot[bot] cf3703e42e
Bump org.junit-pioneer:junit-pioneer from 1.6.1 to 1.6.2 (#3076) 12 months ago
dependabot[bot] 1c4dd41488
Bump kr.motd.maven:os-maven-plugin from 1.6.2 to 1.7.1 (#3063) 12 months ago
dependabot[bot] 5882d50a4f
Bump mikepenz/action-junit-report from 2 to 4 (#3064) 12 months ago
sgibb ec1d0c9009
Makes TestEnableWebfluxSecurityAutoConfiguration conditional on spring security clasess 12 months ago
sgibb 05158e7156
Creates TestEnableWebfluxSecurityAutoConfiguration 12 months ago
sgibb 6225e231e6
Temporarily add @EnableWebFluxSecurity 12 months ago
sgibb d533ae7583
More basic mvc documentation 12 months ago
sgibb c22e4f9e55
Adds dependabot.yml 12 months ago
buildmaster b1d5ccd472 Going back to snapshots 12 months ago
buildmaster da064b990f Update SNAPSHOT to 4.1.0-M2 12 months ago
buildmaster 03c6e23da6 Bumping versions 1 year ago
sgibb 2eda426a32
Updates antora extension and ui 1 year ago
buildmaster 65601bb73e Bumping versions 1 year ago
sgibb 75c5dbac42
Reference 4.0.x for docs 1 year ago
sgibb 64804a8ef8
Adds antora bits to ignore 1 year ago
buildmaster e505b4bdc7 Bumping versions 1 year ago
buildmaster 88acc5af5e Bumping versions 1 year ago
sgibb b1208a6e94
Updates title 1 year ago
sgibb 09d7139a99
minor antora docs fixes 1 year ago
sgibb a8f0642cd6
remove tabs migration 1 year ago
sgibb 3c090f1b69
Include intro.adoc in index.adoc and remove from nav.adoc 1 year ago
sgibb e89752c107
Drops prefix `the-` from gateway filter factory adoc files. 1 year ago
sgibb 5162891feb
Migrate to antora documentation 1 year ago
Spencer Gibb 8e4f067ffc
Antora migration (#3050) 1 year ago
Jonathon Henderson 30f5990517
Add ParameterizedTypeReference to ModifyRequestBodyGatewayFilterFactory. Fixes gh-2635 (#3011) 1 year ago
Steve Riesenberg 984882f75a
Specify clientRegistrationId in TokenRelay filter (#2922) 1 year ago
sgibb 6f95267317
Adds HandlerFunctions.forward() 1 year ago
buildmaster eb098a7596 Going back to snapshots 1 year ago
buildmaster c17804888c Update SNAPSHOT to 4.1.0-M1 1 year ago
sgibb a8dc202edf
One RetryTemplate be route. 1 year ago
sgibb 4cffb2d4d2
Use blocking circuit breaker starter 1 year ago
sgibb fed2898db3
Adds spring-cloud-starter-gateway-mvc 1 year ago
buildmaster 9b9885bc8c Bumping versions 1 year ago
buildmaster 475cdbb0ef Bumping versions 1 year ago
buildmaster 693baf3b10 Bumping versions to 4.0.8-SNAPSHOT after release 1 year ago
buildmaster 6dc5efa00e Going back to snapshots 1 year ago
buildmaster bc757fcb23 Update SNAPSHOT to 4.0.7 1 year ago
Ryan Baxter 3d65c7d1fe Merge branch '4.0.x' 1 year ago
Ryan Baxter da5406db3b Merge branch '3.1.x' into 4.0.x 1 year ago
Gonçalo Marques 6935fe74d7 Fix incorrect cast in NettyRoutingFilter 1 year ago
Ryan Baxter aac3b3edb7
Merge pull request #3008 from GonMMarques/main 1 year ago
Gonçalo Marques ba030a65df
Fix incorrect cast in NettyRoutingFilter 1 year ago
sgibb 8becfeee75
Converts class to record 1 year ago
sgibb 34f65539d3
Updates javadoc comment 1 year ago
sgibb fb1fdbabc2
Adds BodyFilterFunctions.modifyRequestBody() 1 year ago
sgibb f94521e294
Removes old comment 1 year ago
sgibb ad216211b5
Add toString() for never routeˆ 1 year ago
sgibb aef79a3507
polish for loggingˆ 1 year ago
sgibb 2796d39a2c
Adds GatewayDelegatingRouterFunction.toString()ˆ 1 year ago
sgibb 79807d1ddd
Adds GatewayRequestPredicates.readBody() 1 year ago
sgibb b3df870623
Adds GatewayRequestPredicates.weight() 1 year ago
sgibb b393452869
Adds assertions for httpbin properties 1 year ago
sgibb 9f39a02b6b
Uses MvcUtils.setRouteId() rather than set attr by hand. 1 year ago
sgibb afa110ad55
Uses GatewayRouterFunctions.route() 1 year ago
sgibb 0655bdcbda
Adds RemoveContentLengthRequestHeadersFilter 1 year ago
sgibb b7d9662195
Adds TransferEncodingNormalizationRequestHeadersFilter 1 year ago
sgibb 4178c046ef
formats comment 1 year ago
sgibb eb0b641c81
Adds GatewayRequestPredicates.cloudFoundryRouteService() 1 year ago
sgibb bbeb04a7ea
Optional is not a replacement for an if statement. 1 year ago
sgibb bd2d5b0518
reduces test loggingˆ 1 year ago
sgibb 7b0184ec97
Adds BeforeFilterFunctions.fallbackHeaders() 1 year ago
sgibb a953d3897e
Adds AfterFilterFunctions.rewriteLocationResponseHeader() 1 year ago
sgibb 9fecca67be
Adds TokenRelayFilterFunctions.tokenRelay() 1 year ago
sgibb 11ef20d6f2
Adds AfterFilterFunctions.dedupeResponseHeader() 1 year ago
sgibb cf39b20ae2
Adds BeforeFilterFunctions.addRequestHeadersIfNotPresent() 1 year ago
sgibb 335394b6cc
Adds BeforeFilterFunctions.mapRequestHeader() 1 year ago
sgibb 528915b4c3
Changes AfterFilterFunctions to an abstract class. 1 year ago
sgibb 58f6a28866
Adds BeforeFilterFunctions.requestHeaderToRequestUri() 1 year ago
sgibb 05cffd6ed6
Adds BeforeFilterFunctions.requestHeaderSize() 1 year ago
sgibb accd097560
Adds BeforeFilterFunctions.requestSize() 1 year ago
sgibb 52aec742be
Adds AfterFilterFunctions.rewriteResponseHeader() 1 year ago
sgibb 40580ccf0f
Simplifies response header assertions. 1 year ago
sgibb 89ef7dfd7c
Adds AfterFilterFunctions.removeResponseHeader() 1 year ago
sgibb 1863ade599
removes unneeded cast to GatewayServerResponse for header manipulation. 1 year ago
sgibb dfec3130b8
Adds BeforeFilterFunctions.removeRequestParameter() 1 year ago
sgibb 27fe6e050f
Adds more configuration to Bucket4jFilterFunctions.RateLimitConfig 1 year ago
sgibb ee6fdd8e59
Formats comment 1 year ago
sgibb b7dd4e5608
Renames Config classes for easier static import. 1 year ago
sgibb a21fb31407
Adds CircuitBreakerFilterFunctions.Config 1 year ago
sgibb 2a99f7cefd
Changes List to Set in RetryFilterFunctions.Config. 1 year ago
sgibb 8bd118e8fb
Makes RetryFilterFunctions.Config a builder. 1 year ago
sgibb 009dbdb42c
Adds HttpStatusHolder.resolve() to simplify getting the HttpStatusCode. 1 year ago
sgibb 540c0100ea
Uses RouterFunction.and() rather than andOther() 1 year ago
sgibb 968261cc5e
Adds nested route example. 1 year ago
sgibb 1b3adef59f
Adds basic configuration to RetryFilterFunctions. 1 year ago
sgibb 5202c773fd
Updates to use BeforeFilterFunctions.routeId() 1 year ago
sgibb e67165cf72
Adds BeforeFilterFunctions & AfterFilterFunctions 1 year ago
sgibb 403d773dc9
Adds FilterFunctions.setResponseHeader() 1 year ago
sgibb 113b23b443
Adds FilterFunctions.setRequestHostHeader() 1 year ago
sgibb 8c25d06970
Adds FilterFunctions.setRequestHeader() 1 year ago
sgibb e12d6b4d1a
Adds GatewayRouterFunctions.route() 1 year ago
sgibb aa2841db3d
Reorders imports 1 year ago
sgibb ec81c9ab16
Removes unused import 1 year ago
sgibb 5c0a088e71
Removes GatewayServerMvcAutoConfiguration.clientHttpRequestFactoryProxyExchange 1 year ago
sgibb ac4f95045d
Makes RestClientProxyExchange the default. 1 year ago
sgibb 5452046f91
fixes import order 1 year ago
sgibb 2c6ba7d954
Adds HttpbinTestcontainers support 1 year ago
sgibb 12ab65542d
Adds FilterFunctions.removeRequestHeader() 1 year ago
sgibb f9ce745e5e
Adds FilterFunctions.redirectTo() 1 year ago
sgibb a628d24fae
Uses new JDK http client support in ClientHttpRequestFactories 1 year ago
sgibb ba0dfb4999
Adds preserveHost filter. 1 year ago
sgibb 934bb12942
removes TODOˆ 1 year ago
sgibb 7cbb9281d9
removes unneeded catch blockˆ 1 year ago
sgibb 23cc0c3386
changes to use UncheckedIOException 1 year ago
Spencer Gibb ad34a9689a
MVC Gateway Server (#2949) 1 year ago
buildmaster e09b605633 Bumping versions 1 year ago
buildmaster eeecc4599a Bumping versions to 3.1.9-SNAPSHOT after release 1 year ago
buildmaster 764407f8ab Going back to snapshots 1 year ago
buildmaster 78efb0b30c Update SNAPSHOT to 3.1.8 1 year ago
sgibb 98ccd635e0
Merge branch '4.0.x' 1 year ago
sgibb fba558aade
Updates WeightCalculatorWebFilter to be more testable. 1 year ago
sgibb e17509648f
Disables test for jdk 17+ 1 year ago
sgibb 28baf1d381
Disable blockhound junit integration for jdk > 17 1 year ago
sgibb d8c6eb2641
Merge branch '4.0.x' 1 year ago
sgibb 5df34a7e08
Small regex refactor 1 year ago
sgibb 05dca9dfaf
Removed TracingProperties bean as it is no longer needed. 1 year ago
sgibb f98aa6d47b
removes method removed in framework 6.1 1 year ago
sgibb f7587bc688
Updates version to 4.1.0-SNAPSHOT 1 year ago
sgibb 4e8da33734
Merge branch '4.0.x' 1 year ago
sgibb 38e2d07d1c
Merge branch '3.1.x' into 4.0.x 1 year ago
sgibb d8d5bc071b
Removes predicate path exchange attr for forwards. 1 year ago
sgibb 7f1b1927ab
Run test with random port 1 year ago
buildmaster 9073d3ec35 Bumping versions 1 year ago
sgibb 0d876cab1b
Updates version to 4.1.0-SNAPSHOT 1 year ago
buildmaster 4aeccc736e Bumping versions 1 year ago
buildmaster 48b30069f7 Bumping versions 1 year ago
buildmaster 9aadd6138f Bumping versions to 4.0.7-SNAPSHOT after release 1 year ago
buildmaster 71c2e1b52b Going back to snapshots 1 year ago
buildmaster f75cab542f Update SNAPSHOT to 4.0.6 1 year ago
spencergibb fcaceea395
Disables test for release 1 year ago
spencergibb 2269b1977f
Revert "Adds produces to post /routes" 1 year ago
spencergibb bcc2e0f1f6
Revert "Attempts to fix test for release" 1 year ago
spencergibb d98d62bdea
Attempts to fix test for release 1 year ago
spencergibb a545731d78
Adds produces to post /routes 1 year ago
spencergibb 78fe1205a3
Added original constructor back and made fields private. 1 year ago
Marta Medio c97d09d6c4
Response Cache filter must read default config if no route config is defined (#2948) 1 year ago
buildmaster ba814ce930 Bumping versions to 4.0.6-SNAPSHOT after release 1 year ago
buildmaster 07e9ca7867 Going back to snapshots 1 year ago
buildmaster 5399116612 Update SNAPSHOT to 4.0.5 1 year ago
buildmaster 740bcae832 Bumping versions 1 year ago
buildmaster 2e643e7283 Bumping versions to 3.1.8-SNAPSHOT after release 1 year ago
buildmaster 4f33b00291 Going back to snapshots 1 year ago
buildmaster 4dba68ffd6 Update SNAPSHOT to 3.1.7 1 year ago
spencergibb ada2cae551
Merge branch '3.1.x' 1 year ago
spencergibb 1c121efc6e
Support response-timeout property as a String 1 year ago
spencergibb e940ce9783
Update for apache httpclient 5 1 year ago
spencergibb b35e8cc3ed
Formatting 1 year ago
Marta Medio 8120303121
Adding grpc-status header value (adapted for 3.1.x) (#2938) 1 year ago
Marta Medio 064684a31b
Adding grpc-status header value (adapted for 3.1.x) (#2938) 1 year ago
Ignacio Lozano c74d65aa14
Add metadata requestParam to /refresh specific routes (#2916) 1 year ago
Ignacio Lozano 23ca3721a6
Add a new endpoint POST /routes (#2915) 1 year ago
buildmaster 964cb81932 Bumping versions 1 year ago
Ignacio Lozano f1ea09ae3e
Fix bug when combining LocalResponseCache (#2930) 1 year ago
spencergibb c7014f8431
Merge branch '3.1.x' 1 year ago
jiangyuan04 3d44588745
fix grpc MethodDescriptor fullMethodName problem 1 year ago
buildmaster 84fd7cb739 Bumping versions 1 year ago
buildmaster 59839df5fd Bumping versions 1 year ago
Ryan Baxter 7dda1cb62c Merge branch '3.1.x' 1 year ago
Ryan Baxter 2bb47feb47
Merge pull request #2918 from ryanjbaxter/use-new-path-attribute-in-cb-filter 1 year ago
Ryan Baxter 91b465a6b0 Remove gateway predicate path attribute in CB filter. 1 year ago
buildmaster 5e9d2ce0c5 Bumping versions to 4.0.5-SNAPSHOT after release 2 years ago
buildmaster 96092f8611 Going back to snapshots 2 years ago
buildmaster fdc63b1e98 Update SNAPSHOT to 4.0.4 2 years ago
buildmaster 66cb7ed297 Bumping versions 2 years ago
spencergibb 9bedec09f8
Merge branch '3.1.x' 2 years ago
spencergibb 4968a04710
Updated to String.format() 2 years ago
spencergibb 6e06b9661e
Formatting 2 years ago
Ignacio Lozano a4182c04c8
Test invalid URI raises early error before /refresh 2 years ago
Marta Medio bc57f129e4
Allow to deactivate global cache (#2895) 2 years ago
Ignacio Lozano 162863020d
Remove duplicated DataBuffer that caused leak alert by LocalResponseCache (#2886) 2 years ago
Olga Maciaszek-Sharma 8abdf4be00 Refactor test. 2 years ago
Olga Maciaszek-Sharma 1d6690cdbb
Add hints for Configurable objects supertypes and their generics. (#2890) 2 years ago
spencergibb b42ba9128f
Merge branch '3.1.x' 2 years ago
spencergibb 5d8c2cf898
Polish "Add ServerWebExchange a new attribute for PathContainer to avoid repeating parsePath in PathRoutePredicateFactory." 2 years ago
liruihao 18e116c1c6
Adds attribute for PathContainer to avoid repeating parsePath in PathRoutePredicateFactory 2 years ago
spencergibb b72972a4ca
Merge branch '3.1.x' 2 years ago
spencergibb 9575a3496e
formatting 2 years ago
koo.taejin b31af9eef0
Remove unnecessary exception creation when Creating a CachedBodyOutputMessage. 2 years ago
spencergibb 4c4c6f33b0
Removes explicit setting of kotlin maven plugin version. 2 years ago
spencergibb 044a58b264
Removes reference to boot 2.x. 2 years ago
spencergibb cb18b2a5c2
Merge branch '3.1.x' 2 years ago
ecnabogs 720c8d63d8
Invalid sections numbering 2 years ago
spencergibb d01a17c3df
Merge remote-tracking branch 'origin/main' 2 years ago
spencergibb 75e5049c83
formatting 2 years ago
spencergibb d67a7cd671
Merge branch '3.1.x' 2 years ago
spencergibb ca66cb2400
formattingˆ 2 years ago
daihuabin 06574d689a
Adapt ProxyWebSocketHandler CloseStatus 2 years ago
spencergibb e7610612db
Tokenize x-forwarded-for regardless of whitespace. 2 years ago
spencergibb 218cbe5f50
Updates maven to 3.9.0 2 years ago
Marcin Grzejszczak 429991d2ad Fixed a classcast for gateway observation; fixes gh-2877 2 years ago
buildmaster 07da47aca0 Bumping versions to 4.0.4-SNAPSHOT after release 2 years ago
buildmaster bb310dbff0 Going back to snapshots 2 years ago
buildmaster 535ef315db Update SNAPSHOT to 4.0.3 2 years ago
buildmaster 713e351501 Bumping versions to 3.1.7-SNAPSHOT after release 2 years ago
buildmaster dd0aa46559 Going back to snapshots 2 years ago
buildmaster 2b6deaa611 Update SNAPSHOT to 3.1.6 2 years ago
spencergibb 4db1054c30
Updates to use new TestSocketUtils 2 years ago
spencergibb 30fc2b49a8
Merge branch '3.1.x' 2 years ago
spencergibb 671b4165c3
Polish gh-2872 Fixes for gateway routes on management port. 2 years ago
spencergibb a0e32e9d7a
Updates to use SocketUtilsˆ 2 years ago
Ignacio Lozano 539f0a7d1e
Fix NPE when autoconfigured WebTestClient is used 2 years ago
buildmaster f20456aa3d Bumping versions to 4.0.3-SNAPSHOT after release 2 years ago
buildmaster ee132c0a1b Going back to snapshots 2 years ago
buildmaster 52667321d1 Update SNAPSHOT to 4.0.2 2 years ago
spencergibb bdef15d85f
Merge branch '3.1.x' 2 years ago
spencergibb a2ef4895a4
Fixes for gateway routes on management port. 2 years ago
spencergibb b1d306caeb
Adds apache httpclient version 2 years ago
buildmaster 01afaa2fd1 Bumping versions 2 years ago
spencergibb cbcd85cc02
Merge branch 'mmedio/fix-cors-per-route' 2 years ago
spencergibb a7a4b40e7f
Polishes Fix CORS to process all routes. 2 years ago
Marta Medio 0b60b9bf1d
Fixes CORS config to process all routes. 2 years ago
spencergibb bc3ac05546
Merge branch 'mmedio/fix-global-cache' 2 years ago
spencergibb bcdd8749b2
Polish Fix for Local Response Cache 2 years ago
Marta Medio 08167a2da5
Fixes LocalResponseCache for all routes 2 years ago
buildmaster c844d7cd79 Bumping versions 2 years ago
spencergibb 180a052c76
Moves disabled if github actions to methods 2 years ago
spencergibb 69f75e5687
Disable test on github actions 2 years ago
spencergibb 94d4afded7
Merge branch '3.1.x' 2 years ago
wen-ys aeb7df6ce4
Updates github actions versions 2 years ago
Olga Maciaszek-Sharma e4cd6d3337
Fix registration of hints for Configurables conditional on classes. (#2849) 2 years ago
buildmaster 88a0e4ee0b Bumping versions 2 years ago
spencergibb f2b132e1d8
Removes usages of Optional 2 years ago
buildmaster 6ff9979321 Bumping versions to 3.1.6-SNAPSHOT after release 2 years ago
buildmaster 882cb0c3d6 Going back to snapshots 2 years ago
buildmaster 25d93c1be3 Update SNAPSHOT to 3.1.5 2 years ago
buildmaster 1cd938e448 Bumping versions 2 years ago
buildmaster 1826186e5a Bumping versions to 4.0.2-SNAPSHOT after release 2 years ago
buildmaster 545968eebb Going back to snapshots 2 years ago
buildmaster c3e30c5a93 Update SNAPSHOT to 4.0.1 2 years ago
buildmaster 20aa05fb2c Bumping versions 2 years ago
spencergibb 4dba8bf1e4
Updates to instanceof with variable 2 years ago
spencergibb a2e815b30b
Merge branch '3.1.x' 2 years ago
spencergibb 22536f2702
Formatting for 3.1.x 2 years ago
wen-ys 2d67158c20
Fixes memory lean with cached body 2 years ago
spencergibb 50cec9c312
Removes unused import 2 years ago
spencergibb 7e4f43bbff
Removes unused import 2 years ago
Olga Maciaszek-Sharma b9117f71c9 Decrease log level. Fixes gh-2778. 2 years ago
spencergibb 9d60f16586
Merge branch '3.1.x' 2 years ago
spencergibb 6600555881
Clarifies scope of GlobalFilter to matched routes. 2 years ago
spencergibb 670687c838
Merge branch '3.1.x' 2 years ago
spencergibb baad377db6
Removes jetbrains imports 2 years ago
spencergibb e94887b97b
Update default connectTimeout to 30s according to reactor netty 2 years ago
spencergibb 59b37f0414
Removes deprecated fields/methods. 2 years ago
spencergibb 25abaca600
Injects CacheManager using @Qualifier. 2 years ago
Olga Maciaszek-Sharma 7ed4623809
Add DiscoveryClientRouteDefinitionLocator.DelegatingServiceInstance hints. (#2844) 2 years ago
Simone Gerevini 5ca26cdebc
Wrap CacheKeyGenerator MessageDigest in ThreadLocal (#2829) 2 years ago
Marta Medio b0d9c9af1d
Fix docs for LocalResponseCache Filter (#2843) 2 years ago
spencergibb d01b187923
fixes import order 2 years ago
Tomasz Rup d79f5742da
Add @ConditionalOnMissing bean to FilteringWebHandler (#2308) 2 years ago
spencergibb eec4c8ee52
Merge branch '3.1.x' 2 years ago
spencergibb a057d020c5
Replace circleci badge with github actions 2 years ago
spencergibb 7519b2ef6a
Replace circleci badge with github actions 2 years ago
dengliming 49708a5b07
Update README.adoc to point to main 2 years ago
spencergibb 9913fd980d
Merge branch '3.1.x' 2 years ago
Cristian Ruiz Bonilla 0e23b9bc2f
Throw an error when replenishRate > burstCapacity 2 years ago
ruansheng 49c0b3a32c
Fixes redirect dsl accidental recursion. 2 years ago
ruansheng 65d84afcb8
Fixes redirect dsl accidental recursion. 2 years ago
buildmaster 52dbfeaa5a Bumping versions 2 years ago
Poison 2b19fb0b97
Remove unnecessary reverse (#2664) 2 years ago
Poison 2b8bf25cb0
Fix typo (#2654) 2 years ago
HashJang 2b7f3ef255
add trace log for websocket packet tracing (#2638) 2 years ago
spencergibb c6c813a112
Merge branch '3.1.x' 2 years ago
Oliver 51137c2610
Update documentation for path route predicate 2 years ago
spencergibb a624ba656d
Merge branch '3.1.x' 2 years ago
spencergibb ec76763404
formattingˆ 2 years ago
zhenqiangyi ee5ad6f462
Changes to use ThreadLocalRandom 2 years ago
spencergibb 51a822eb92
removes comments 2 years ago
Tommas Yuan 2c90b25aba
rename test case name for issue 2541 2 years ago
spencergibb 520532b614
removes comments 2 years ago
Tommas Yuan 90e2d31537
rename test case name for issue 2541 2 years ago
Alexandre Arcanjo de Queiroz 8a9d063986
Fix properties in secure-headers documentation 2 years ago
spencergibb d194aa7de9
Removes codacy image 2 years ago
Wenjun Ruan 389ae56a8e
Remove code quality image in README.adoc (#2539) 2 years ago
spencergibb d42c29d6d4
Merge branch 'rate-limiter-lua-script' 2 years ago
jizhuozhi 98b6ffda32
Add tests for request_rate_limiter.lua 2 years ago
spencergibb f6d9692d82
Fixes code example lambda. 2 years ago
spencergibb 7c3729a84c
Merge branch '3.1.x' 2 years ago
lzhpo 5b43c6579f
1. Replace keys with scan when get routeDefinitions. 2 years ago
spencergibb 1f048ae50e
Merge branch 'documentation-fix' 2 years ago
Harpal 6b15aac5b4
Documentation improvement 2 years ago
spencergibb 2f8777c6b0
Merge branch 'YunWZ/main' 2 years ago
YunWZ 3fa21ad3ac
Makes AddResponseHeaderGatewayFilterFactory a 'post' filter. 2 years ago
spencergibb c5add134ca
Merge branch '3.1.x' 2 years ago
Henning Poettker fb2b1c1784
ConditionalOnMissingBean for ReactiveOAuth2AuthorizedClientManager 2 years ago
spencergibb bee680d388
formattingˆ 2 years ago
spencergibb f8df845c61
Migrates to assertj in test 2 years ago
spencergibb cb235831d6
Merge branch '3.1.x' 2 years ago
spencergibb 0fe10b119b
Migrates to assertj in test 2 years ago
wen-ys 0280f96d19
Don't cache body twice. 2 years ago
Junho, Kim e007e6fa30
Enable kotlin route DSL (#2825) 2 years ago
buildmaster ff79c5cc7b Bumping versions 2 years ago
buildmaster 5abc15688a Bumping versions 2 years ago
buildmaster 041691b580 Bumping versions to 4.0.1-SNAPSHOT after release 2 years ago
buildmaster bb24225919 Going back to snapshots 2 years ago
buildmaster e231631c10 Update SNAPSHOT to 4.0.0 2 years ago
spencergibb 52bd92b83b
Update micrometer docs plugin config 2 years ago
spencergibb 7eaee6ba65
Update micrometer docs version to 1.0.0 2 years ago
ruansheng a5ea6ca46b
Fix caffeine class conditional (#2807) 2 years ago
Marcin Grzejszczak 548442dc07
Fix the Kotlin Maven plugin (#2815) 2 years ago
buildmaster fdd348a104 Going back to snapshots 2 years ago
buildmaster a42e29a9a1 Update SNAPSHOT to 4.0.0-RC3 2 years ago
spencergibb 9a5e942d8b
Polish "switch junit 4 tests to junit 5" 2 years ago
Krishna c26a7035df
Fixes gh-2365 switch junit 4 tests to junit 5 (#2794) 2 years ago
spencergibb f2d7d58445
Merge branch '3.1.x' 2 years ago
Marta Medio ab7f79bd08
Avoid ClassCastException when using ServerHttpResponseDecorator 2 years ago
spencergibb 9db7b5e605
Uses TestSocketUtils from spring-framework 2 years ago
spencergibb c527a4c1e1
Updates io.micrometer:context-propagation to 1.0.0 2 years ago
spencergibb c0504a3777
Merge branch '3.1.x' 2 years ago
yanwenliang 53cc68fbf5
Fix NettyNettyWriteResponseFilter memory leak 2 years ago
buildmaster 2cf190cabf Bumping versions 2 years ago
Ignacio Lozano 04cd541fe7
Allow Global CORS configuration to be disable (#2779) 2 years ago
buildmaster 545c684a0f Going back to snapshots 2 years ago
buildmaster a2e54506a3 Update SNAPSHOT to 4.0.0-RC2 2 years ago
spencergibb be8e3fb2c5
Avoid direct URL construction. 2 years ago
Marta Medio 50922f7dd8
Filter Documentation improvements (#2761) 2 years ago
buildmaster be2abff70e Bumping versions 2 years ago
Ryan Baxter 0ca0cfe37e
Merge pull request #2773 from ilozano2/ilozano/cors-allowCredentials-typo 2 years ago
Olga Maciaszek-Sharma 3f3f77313e Add more native hints. 2 years ago
Ignacio Lozano 3c5e4841e3 Correct typo in CORS listener 2 years ago
buildmaster 63e731c4ab Bumping versions 2 years ago
Olga Maciaszek-Sharma 477e864411 Make ConfigurableHintsRegistrationProcessor static. 2 years ago
Marcin Grzejszczak 64987caca3 Micrometer-Observation is a mandatory dependency for webflux 2 years ago
Marcin Grzejszczak 67f3fe7df3
Adds the original Reactor Context to ServerWebExchange attributes (#2772) 2 years ago
Olga Maciaszek-Sharma 5182f49236
Add native image support. (#2770) 2 years ago
Olga Maciaszek-Sharma 7bdb396512 Remove incorrect annotations. 2 years ago
Marcin Grzejszczak 39abddcd5b
Shouldn't remove remote fields from gateway propagation (#2764) 2 years ago
buildmaster 4a16c447fb Going back to snapshots 2 years ago
buildmaster a53fa99e44 Update SNAPSHOT to 4.0.0-RC1 2 years ago
buildmaster 8a6dc328b8 Bumping versions 2 years ago
spencergibb f779d16e8e
Polishes Add LocalResponseCache filter gh-2759 2 years ago
Ignacio Lozano 8a0caeea41
Add LocalResponseCache filter (#2759) 2 years ago
spencergibb 3e83068cc2
formatting 2 years ago
spencergibb 4686553e19
X-Xss-Protection header now set by spring security automatically 2 years ago
Marcin Grzejszczak 64952e437e Added a dedicated entry in ServerWebExchangeUtils for Observation 2 years ago
Marcin Grzejszczak 8b09ea723c Ensured the order of tracing handlers 2 years ago
Marcin Grzejszczak df0a4c3243 Added better logg for observations 2 years ago
buildmaster 62e0f241d2 Bumping versions 2 years ago
spencergibb 2b0371a928
Adds suppress warnings 2 years ago
spencergibb 414a88003c
Only finds path predicate if cors configuration is found 2 years ago
spencergibb 1e0fa220af
formatting 2 years ago
Abel Salgado Romero d49ceec0d2
Add uri variables support for circuit breaker (#2755) 2 years ago
Abel Salgado Romero 074f8e9844
Add option to configure CORS as a route filter. (#2750) 2 years ago
spencergibb 5127bd3272
Migrates test to apache http client5 2 years ago
Marcin Grzejszczak a607840683 Fixed Micrometer compilation issues 2 years ago
buildmaster a11973f98b Going back to snapshots 2 years ago
buildmaster 4ef34a2615 Update SNAPSHOT to 4.0.0-M5 2 years ago
spencergibb 12a5ff35e7
Polish gh-2742 2 years ago
Marta Medio a487e64bfd
Add remove json attributes filter (#2742) 2 years ago
spencergibb 253eec53a8
Merge branch 'add-AddRequestHeadersIfNotPresentGatewayFilterFactory-2359' 2 years ago
spencergibb 34673a9de8
Polish gh-2737 2 years ago
Abel Salgado Romero f45d03ec1d Add docs 2 years ago
Abel Salgado Romero f998ca4f75 Add support for URI variables 2 years ago
Abel Salgado Romero 5db6f63599 Add AddRequestHeadersIfNotPresentGatewayFilterFactory 2 years ago
Marcin Grzejszczak db35e58264
Attaches error to Observation (#2743) 2 years ago
Marcin Grzejszczak f2192b0770
Observability support for gateway (#2715) 2 years ago
spencergibb 8bd257710a
Migrates to AutoConfiguration.imports 2 years ago
buildmaster 2d161a3d8b Bumping versions 2 years ago
buildmaster 7873f854b5 Going back to snapshots 2 years ago
buildmaster 1ae40a4431 Update SNAPSHOT to 3.1.4 2 years ago
buildmaster 21a6b68349 Bumping versions to 3.1.5-SNAPSHOT after release 2 years ago
buildmaster 36edcd5929 Going back to snapshots 2 years ago
buildmaster 3791cb593c Update SNAPSHOT to 3.1.4 2 years ago
buildmaster da137d9940 Bumping versions 2 years ago
spencergibb c3b81538f7
Removes deprecated methods in HttpClientFactory 2 years ago
spencergibb cbb86f8681
Merge branch '3.1.x' 2 years ago
spencergibb d5e95a6aab
Changes @ConditionalOnClass to use `name` rather than value 2 years ago
spencergibb bf87531ce0
Merge branch 'v3.1.x/arios/keystore-grpc' into 3.1.x 2 years ago
spencergibb 0b58d77102
Polish gh-2699 Updates HttpClientFactory for backwards compatibility 2 years ago
Abel Salgado Romero 774975a0fe
Adds support for 'use-insecure-trust-manager' & 'trustedX509Certificates' for GRPC Filter 2 years ago
spencergibb 4f5fb18927
Updates to testcontainers 1.17.3 2 years ago
spencergibb c98a11f5fb
Moves to new redis prefix 2 years ago
Alberto C. Ríos 22a9aec8bf * Bump testcontainers 2 years ago
buildmaster 0568b306da Bumping versions 2 years ago
spencergibb ab36805eb3
Switch @ConditionalOnClass to use name 2 years ago
spencergibb 310487ff27
Switch @ConditionalOnClass to use name 2 years ago
buildmaster 604499f215 Going back to snapshots 2 years ago
buildmaster 56cd7d46c0 Update SNAPSHOT to 4.0.0-M4 2 years ago
Ryan Baxter 06c7d85a18 Removing dirtiescontext from tests 2 years ago
Ryan Baxter 055d5d882d Fixing import order 2 years ago
Ryan Baxter 57ffad7908 Adding import 2 years ago
Ryan Baxter a3ac771065 Adding dirtiescontext to test 2 years ago
buildmaster 52fca92b05 Bumping versions 2 years ago
Jonatan Ivanov c28e7e027e
Fix Blockhound config for micrometer-context-propagation 2 years ago
spencergibb 64f13b875c
Updates annotation package 2 years ago
spencergibb 8ec0b92fcf
Merge branch '3.1.x' 2 years ago
Alberto C. Ríos 1843547e20
Adding native JSON to gRPC filter (#2657) 2 years ago
buildmaster 8d56d9ab04 Bumping versions 2 years ago
spencergibb da34d362ee
Adds explicit / mapping 2 years ago
spencergibb 1e409c5aaf
Merge branch '3.1.x' 2 years ago
Robert McNees e739628323
Updates github action maven build parameters 2 years ago
buildmaster 26b8e7dde6 Bumping versions 2 years ago
buildmaster 645f7a2cec Bumping versions 2 years ago
buildmaster faf61ab784 Bumping versions 2 years ago
spencergibb f14abf55ba
Merge branch '3.1.x' 2 years ago
Alberto C. Ríos 5fc1f291c7
Updating log level when invalid route (#2616) 2 years ago
Alberto C. Ríos 43f52c88c4
Updating RemoveHopByHopHeadersFilter precedence (#2614) 2 years ago
buildmaster 576bc1c497 Going back to snapshots 2 years ago
buildmaster 08d3902f72 Update SNAPSHOT to 4.0.0-M3 2 years ago
spencergibb 7c55d977de
Bumps to next snapshot version 2 years ago
buildmaster 4167afdeea Update SNAPSHOT to 3.1.3 2 years ago
Spencer Gibb d79d699afd
don't upload docs to maven central 2 years ago
spencergibb b8dbdc1fbf
Merge branch '3.1.x' 2 years ago
Robert McNees ad7a0b95b7
Prefix path uses path variables. 2 years ago
spencergibb 6b93ff9979
Add micrometer to blockhound config 2 years ago
spencergibb 3a78e666cb
Moves to new LocalServerPort location 2 years ago
spencergibb b7e8a8f0ef
Updates to use new HttpStatusCode references/methods 2 years ago
buildmaster 3599efcb7e Bumping versions 2 years ago
buildmaster da8b3c3149 Bumping versions to 3.1.3-SNAPSHOT after release 2 years ago
buildmaster 1d01a5781e Going back to snapshots 2 years ago
buildmaster 735fd52f1a Update SNAPSHOT to 3.1.2 2 years ago
Olga Maciaszek-Sharma 04668960bc Revert "Update SNAPSHOT to 3.1.2" 2 years ago
Olga Maciaszek-Sharma 8f104153e1 Revert "Going back to snapshots" 2 years ago
Olga Maciaszek-Sharma f025a0f042 Revert "Bumping versions to 3.1.3-SNAPSHOT after release" 2 years ago
Olga Maciaszek-Sharma 0181217743 Revert "Bumping versions" 2 years ago
buildmaster 83ebee5bd7 Bumping versions 2 years ago
buildmaster 013c0e2b60 Bumping versions to 3.1.3-SNAPSHOT after release 2 years ago
buildmaster 8c461a3786 Going back to snapshots 2 years ago
buildmaster 9219ffe8ee Update SNAPSHOT to 3.1.2 2 years ago
buildmaster aaa52670ca Going back to snapshots 3 years ago
buildmaster 533bfb58a4 Update SNAPSHOT to 4.0.0-M2 3 years ago
Olga Maciaszek-Sharma f347bd8302 Merge 3.1.x. 3 years ago
Olga Maciaszek-Sharma bf82c10ddc Merge remote-tracking branch 'origin/3.1.x' 3 years ago
Olga Maciaszek-Sharma 5aa97ffdce Adjust to changes in commons. 3 years ago
spencergibb 1b4e3ee42e
Merge branch '3.1.x' 3 years ago
spencergibb 3e9154e2cc
formatting 3 years ago
spencergibb ec07a67930
Fixes RequestHeaderSizeGatewayFilterFactory to check individual headers. 3 years ago
Marta Medio ed88edd3a8
Updates RequestHeaderSize existing filter to also take into account key size 3 years ago
spencergibb fc31ccbcfc
Merge branch '3.1.x' 3 years ago
tommas 0dd2a47d8d
Merges upstream headers with that defined by gateway server, not overwrite them. 3 years ago
spencergibb 4154176b99
Cleanup deprecations and warnings 3 years ago
spencergibb b1c34a1521
Migrates to TestSocketUtils from spring-cloud-test-support 3 years ago
spencergibb 66611ab36d
run test on random port 3 years ago
spencergibb e226b78215
Updates junit-pioneer 3 years ago
buildmaster 8d32e3aa8e Bumping versions 3 years ago
buildmaster cc2b6e4352 Bumping versions 3 years ago
spencergibb 3b5aedbbf3
enables gateway actuator for test 3 years ago
buildmaster d5ed2a3c64 Bumping versions to 3.1.2-SNAPSHOT after release 3 years ago
buildmaster d2652f9e51 Going back to snapshots 3 years ago
buildmaster d66ab832d1 Update SNAPSHOT to 3.1.1 3 years ago
spencergibb 25fb7475a7
Disables gateway actuator by default 3 years ago
spencergibb 39cc3daf46
Separates ShortcutConfigurableNonRestrictiveTests 3 years ago
spencergibb d7f44288cf
Adds spring.cloud.gateway.restrictive-property-accessor.enabled 3 years ago
spencergibb 337cef276b
Updates ShortcutConfigurable to use custom EvaluationContext. 3 years ago
spencergibb c1870a116f
Moves configuration of HttpClient. 3 years ago
spencergibb 849c0d6a64
Separates ShortcutConfigurableNonRestrictiveTests 3 years ago
spencergibb 818fdb653e
Merge branch 'spel-context-fix' into 3.1.x 3 years ago
spencergibb 7162b59dcd
Merge branch 'configure-httpclientfactory' into 3.1.x 3 years ago
buildmaster dcde0bc2ad Bumping versions 3 years ago
spencergibb a1a1e5fa70
Merge branch '3.1.x' 3 years ago
spencergibb 2ab1d233ca
Adds XForwarded Remote Addr predicate doc 3 years ago
Jelle Druyts 8b685b18ca
Add route predicate for "X-Forwarded-For" header 3 years ago
spencergibb c76b775370
Adds spring.cloud.gateway.restrictive-property-accessor.enabled 3 years ago
spencergibb 34a5e0b860
Merge branch '3.1.x' 3 years ago
spencergibb d5a9a21a5e
Updates grpc in integration tests 3 years ago
spencergibb bf9e98bced
Updates testcontainers to latest versions 3 years ago
spencergibb f8db47ee62
Updates testcontainers to latest versions 3 years ago
Abel Salgado Romero c4323a83b2
Fix example in SetStatusGatewayFilterFactory docs 3 years ago
spencergibb 2befc5804c
Adds path predicate regex test 3 years ago
Abel Salgado Romero 6a5d723406
Fix example in SetStatusGatewayFilterFactory docs 3 years ago
spencergibb e47e5fc20d
Adds path predicate regex test 3 years ago
spencergibb d8c255eddf
Updates ShortcutConfigurable to use custom EvaluationContext. 3 years ago
buildmaster e85ea01f88 Bumping versions 3 years ago
spencergibb 5ba2b1a554
Removes reference to building-jdk8 3 years ago
spencergibb a2f9d82f96
Updates docs to java 17, Spring 6 & Boot 3 3 years ago
spencergibb b2df97d0c4
Moves configuration of HttpClient. 3 years ago
Abel Salgado Romero bc54c58beb
Fix invalid backticks in the docs 3 years ago
Abel Salgado Romero b54167d634
Fix invalid backticks in the docs 3 years ago
buildmaster ab3fcdfd58 Going back to snapshots 3 years ago
buildmaster df7f8a2ce5 Update SNAPSHOT to 4.0.0-M1 3 years ago
spencergibb 3571e73165
Adds javadoc to enums 3 years ago
spencergibb 162409f6fc
formatting 3 years ago
buildmaster 7c50a3ae18 Bumping versions 3 years ago
spencergibb 2945f4b486
Merge branch '3.1.x' 3 years ago
spencergibb 545a8358fc
remove circleci 3 years ago
spencergibb 32e97867e2
github actions support for 3.1.x 3 years ago
spencergibb 2ea1bcaf91
put test output in a file 3 years ago
spencergibb fa9e51099e
fixes yaml formatting 3 years ago
spencergibb d49106ac17
adds tests back 3 years ago
spencergibb 860311b758
temporarily skip tests 3 years ago
spencergibb 1a0af010df
Merge branch '3.1.x' 3 years ago
spencergibb f9e8915e01
Moves away from -local spring repos 3 years ago
spencergibb de9c2c73fe
Disables test on github actions 3 years ago
spencergibb 0356a638a5
Adds github actions build 3 years ago
spencergibb 29ea253cd8
Updates circleci for java17 3 years ago
spencergibb b4566ef34c
Updates circleci for java17 3 years ago
spencergibb d692e0e24c
Updates circleci for java17 3 years ago
buildmaster e9c89eaa35 Bumping versions 3 years ago
spencergibb 49d312f706
Updates to version 4.0.0-SNAPSHOT 3 years ago
spencergibb c1c4cfb7b8
Updates to version 4.0.0-SNAPSHOT 3 years ago
spencergibb 32ab43685f
Adds .sdkmanrc 3 years ago
buildmaster 1ba609d1d4 Bumping versions 3 years ago
spencergibb 03b9d8479d
Merge branch '3.0.x' 3 years ago
spencergibb 84ddb3ed74
Merge branch '3.0.x' 3 years ago
buildmaster aeb011d1c1 Bumping versions 3 years ago
buildmaster adf4f9d842 Bumping versions to 3.1.1-SNAPSHOT after release 3 years ago
buildmaster 0e43efeb2c Going back to snapshots 3 years ago
buildmaster e5471d91f8 Update SNAPSHOT to 3.1.0 3 years ago
buildmaster 79bb7e636d Bumping versions 3 years ago
spencergibb cb23319663
Makes ProxyExchange.DEFAULT_SENSITIVE read only. 3 years ago
buildmaster a10b61c8e1 Bumping versions 3 years ago
Muratcan Yurga 73429eb69a
Update _configprops.adoc (#2446) 3 years ago
Robert McNees d7556ab26f
Merge pull request #2440 from robertmcnees/without_docker_profile 3 years ago
Robert McNees e7e199dc0c
New profile to skip Docker tests 3 years ago
Robert McNees 9efafe8d9c
Disable per route response timeout with negative number (#2420) 3 years ago
spencergibb 514c4d7c40
Merge branch '3.0.x' 3 years ago
Olga Maciaszek-Sharma 3308a493ea
Use LoadBalancer per-client properties. (#2426) 3 years ago
buildmaster 33cfdc69ee Bumping versions 3 years ago
spencergibb b2885b4a0a
Merge branch '3.0.x' 3 years ago
spencergibb 7da74cf21f
Merge branch '3.0.x' 3 years ago
spencergibb d944505616
Merge branch '3.0.x' 3 years ago
spencergibb 72d4ae09b2
Merge branch '3.0.x' 3 years ago
spencergibb cee9dee75f
Merge branch '3.0.x' 3 years ago
spencergibb 7ba4af9d5a
Merge branch '3.0.x' 3 years ago
spencergibb afc83442ce
Merge branch '3.0.x' 3 years ago
buildmaster 38b4977018 Bumping versions 3 years ago
Spencer Gibb 665d7df1e6
Adds Visitor pattern to visit each node of Predicate. (#2423) 3 years ago
spencergibb 5620be9fc5
Merge branch '3.0.x' 3 years ago
spencergibb f2f25772b5
Merge branch '3.0.x' 3 years ago
spencergibb 436f1386ae
Revert "temporarily pin reactor to 2020.0.12" 3 years ago
buildmaster 51496ad785 Going back to snapshots 3 years ago
buildmaster 742ed94971 Update SNAPSHOT to 3.1.0-M3 3 years ago
spencergibb 70451ff85e
temporarily pin reactor to 2020.0.12 3 years ago
Alberto C. Ríos af09c72a9a
Adding initial gRPC support (#2388) 3 years ago
buildmaster da10105147 Bumping versions 3 years ago
spencergibb 2673993436
Merge branch '3.0.x' 3 years ago
spencergibb 0037ef60f9
Updates mappings to pass tests 3 years ago
spencergibb 96804e8d5d
formatting 3 years ago
spencergibb 347b476eb0
formatting 3 years ago
spencergibb c7540cc1eb
Merge branch '3.0.x' 3 years ago
铁锚 98fa149067
Fix doc mistake about AddResponseHeader (#2366) 3 years ago
spencergibb 856977a068
Removes non-existent module from dependencies. 3 years ago
Bruno Silva 19561a97d1
Fix ConcurrentModificationException (#2299) 3 years ago
spencergibb 96488230a6
Merge branch 'jkschneider-refactor/polish-request-mapping-annotations' 3 years ago
spencergibb ed1f203fce
Merge branch 'refactor/polish-request-mapping-annotations' of git://github.com/jkschneider/spring-cloud-gateway into jkschneider-refactor/polish-request-mapping-annotations 3 years ago
spencergibb 26f132ddfe
Merge branch 'abelsromero-fix-timer-metric-name' 3 years ago
spencergibb 2e4473d970
Merge branch 'fix-timer-metric-name' of https://github.com/abelsromero/spring-cloud-gateway into abelsromero-fix-timer-metric-name 3 years ago
spencergibb 2950ce703f
Merge branch '3.0.x' 3 years ago
Vladimir Plizga 82fe6a21a8
Move RemoteAddressResolvers doc paragraph (#2272) 3 years ago
Vladimir Plizga 123654e5c8
Add @Component annotation and some notes to custom components description (#2269) 3 years ago
Alex Lin 61c9352856
fix: variable `type` not used. (#2264) 3 years ago
Ingyu Hwang (Evan) 9b3486e5fa
Delete circle-v1.yml (#2260) 3 years ago
buildmaster a264598c78 Going back to snapshots 3 years ago
buildmaster 348de38286 Update SNAPSHOT to 3.1.0-M2 3 years ago
buildmaster 8d95340401 Bumping versions 3 years ago
spencergibb 64779d12b1
changes http2 tests to use WebClient 3 years ago
spencergibb 06fbda8f4d
adds explicit classes to to http2 tests 3 years ago
spencergibb 597ee495d7
adds error logging to http2 tests 3 years ago
spencergibb f5f23ce61f
restores http2 termination tests 3 years ago
spencergibb c1eb83cd38
fixes checkstyle by adding newline at the end of file 3 years ago
Spencer Gibb 9d178e2217
HTTP2 Support (#2363) 3 years ago
buildmaster e553925df2 Bumping versions 3 years ago
spencergibb c32eba11c4
Merge branch 'gh_2314' 3 years ago
spencergibb 73b1f7a243
Changes how redis tests get configuration from Testcontainers. 3 years ago
Robert McNees e51f2bdf07 Changes for redis and docker test to run 3 years ago
Robert McNees 36d8885880 Formatting 3 years ago
Robert McNees 90b31b8138 Removed host from configurable app context 3 years ago
Robert McNees ea756e587b Formatting changes 3 years ago
Robert McNees cd8ab7ddb3 Enabled Redis tests 3 years ago
Olga Maciaszek-Sharma 9d6863b051
Fix on jdk 17 (#2367) 3 years ago
spencergibb 26f86fefb6
Merge branch '3.0.x' 3 years ago
Ryan Baxter bb0decca42
Merge pull request #2339 from giger85/feature/fix-typo-custom-route-predicate 3 years ago
giger85 8bfe62bd4f Fix typo in Custom Route Predicate 3 years ago
r-asou a13f249153
modify doc mistake (#2310) 3 years ago
buildmaster b558bce895 Going back to snapshots 3 years ago
buildmaster cf1fbc6b1f Update SNAPSHOT to 3.1.0-M1 3 years ago
buildmaster eda92db12a Bumping versions 3 years ago
DanielWei ec34a99f34
add cache request body filter (#1943) 3 years ago
spencergibb 51ff3685d6
Changes default of StripPrefix filter from 0 to 1. 3 years ago
spencergibb 16a29c1f2b
formatting 3 years ago
spencergibb c6469fdf47
Merge branch 'tswstarplanet-filter_list' 3 years ago
spencergibb 0aa73a406a
formatting 3 years ago
tswstarplanet 8019ada2b8
Filters all instances in DiscoveryClientRouteDefinitionLocator 3 years ago
spencergibb 5002fe2e0a
polish and update tests 3 years ago
spencergibb 4d5f4abb0d
Merge branch 'dennis-menge-master' 3 years ago
DanielWei ea6464af8a
Adds various improvements to RedisRouteDefinitionRepository. 3 years ago
Dennis Menge 21960d2c7b
Adds persistent Redis Route Repository implementation 3 years ago
spencergibb 54eb6046f8
removes deployment repo 3 years ago
buildmaster 142d9c2ce2 Bumping versions 3 years ago
spencergibb 884c3ab806
Attempt to appease Blockhound #2 3 years ago
spencergibb a7d442ba5d
Attempt to appease Blockhound 3 years ago
spencergibb 2d36c6dfdd
Updates javadoc 3 years ago
Jonathan Schneider 5fa200b95b refactor: Polish `@RequestMapping` annotations 3 years ago
spencergibb 52ffee5aae
Adds index.adoc file with include 3 years ago
spencergibb 28d8bd5e8d
Delete index.adoc symlink 3 years ago
spencergibb c54e90eb5e
Updates version to 3.1.0-SNAPSHOT 3 years ago
Abel Salgado Romero 9361833f18 Fix timer metric name in docs 3 years ago
  1. 44
      .circleci/config.yml
  2. 49
      .github/dependabot.yml
  3. 32
      .github/workflows/deploy-docs.yml
  4. 37
      .github/workflows/maven.yml
  5. 7
      .gitignore
  6. 2
      .mvn/maven.config
  7. BIN
      .mvn/wrapper/maven-wrapper.jar
  8. 19
      .mvn/wrapper/maven-wrapper.properties
  9. 3
      .sdkmanrc
  10. 222
      README.adoc
  11. 36
      circle-v1.yml
  12. 39
      docs/antora-playbook.yml
  13. 12
      docs/antora.yml
  14. BIN
      docs/modules/ROOT/assets/images/gateway-grafana-dashboard.jpeg
  15. BIN
      docs/modules/ROOT/assets/images/spring_cloud_gateway_diagram.png
  16. 77
      docs/modules/ROOT/nav.adoc
  17. 2
      docs/modules/ROOT/pages/_attributes.adoc
  18. 17
      docs/modules/ROOT/pages/appendix.adoc
  19. 6
      docs/modules/ROOT/pages/configprops.adoc
  20. 1
      docs/modules/ROOT/pages/index.adoc
  21. 6
      docs/modules/ROOT/pages/intro.adoc
  22. 72
      docs/modules/ROOT/pages/spring-cloud-gateway-proxy-exchange.adoc
  23. 5
      docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc.adoc
  24. 11
      docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/glossary.adoc
  25. 17
      docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/how-it-works.adoc
  26. 41
      docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/java-routes-api.adoc
  27. 14
      docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/starter.adoc
  28. 7
      docs/modules/ROOT/pages/spring-cloud-gateway.adoc
  29. 291
      docs/modules/ROOT/pages/spring-cloud-gateway/actuator-api.adoc
  30. 8
      docs/modules/ROOT/pages/spring-cloud-gateway/aot-and-native-image-support.adoc
  31. 5
      docs/modules/ROOT/pages/spring-cloud-gateway/configuration-properties.adoc
  32. 45
      docs/modules/ROOT/pages/spring-cloud-gateway/configuration.adoc
  33. 50
      docs/modules/ROOT/pages/spring-cloud-gateway/configuring-route-predicate-factories-and-filter-factories.adoc
  34. 61
      docs/modules/ROOT/pages/spring-cloud-gateway/cors-configuration.adoc
  35. 156
      docs/modules/ROOT/pages/spring-cloud-gateway/developer-guide.adoc
  36. 41
      docs/modules/ROOT/pages/spring-cloud-gateway/fluent-java-routes-api.adoc
  37. 10
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories.adoc
  38. 40
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/addrequestheader-factory.adoc
  39. 44
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/addrequestheadersifnotpresent-factory.adoc
  40. 40
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/addrequestparameter-factory.adoc
  41. 41
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/addresponseheader-factory.adoc
  42. 42
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/cacherequestbody-factory.adoc
  43. 168
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/circuitbreaker-filter-factory.adoc
  44. 25
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/deduperesponseheader-factory.adoc
  45. 19
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/default-filters.adoc
  46. 43
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/fallback-headers.adoc
  47. 80
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/jsontogrpc-factory.adoc
  48. 55
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/local-cache-response-filter.adoc
  49. 24
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/maprequestheader-factory.adoc
  50. 44
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/modifyrequestbody-factory.adoc
  51. 24
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/modifyresponsebody-factory.adoc
  52. 23
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/prefixpath-factory.adoc
  53. 21
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/preservehostheader-factory.adoc
  54. 26
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/redirectto-factory.adoc
  55. 42
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/removejsonattributesresponsebody-factory.adoc
  56. 23
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/removerequestheader-factory.adoc
  57. 24
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/removerequestparameter-factory.adoc
  58. 26
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/removeresponseheader-factory.adoc
  59. 23
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/requestheadersize-factory.adoc
  60. 120
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/requestratelimiter-factory.adoc
  61. 35
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/requestsize-factory.adoc
  62. 86
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/retry-factory.adoc
  63. 35
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/rewritelocationresponseheader-factory.adoc
  64. 24
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/rewritepath-factory.adoc
  65. 26
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/rewriterequestparameter-factory.adoc
  66. 24
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/rewriteresponseheader-factory.adoc
  67. 24
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/savesession-factory.adoc
  68. 38
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/secureheaders-factory.adoc
  69. 26
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setpath-factory.adoc
  70. 41
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setrequestheader-factory.adoc
  71. 27
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setrequesthostheader-factory.adoc
  72. 41
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setresponseheader-factory.adoc
  73. 40
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setstatus-factory.adoc
  74. 24
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/stripprefix-factory.adoc
  75. 103
      docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/tokenrelay-factory.adoc
  76. 200
      docs/modules/ROOT/pages/spring-cloud-gateway/global-filters.adoc
  77. 11
      docs/modules/ROOT/pages/spring-cloud-gateway/glossary.adoc
  78. 15
      docs/modules/ROOT/pages/spring-cloud-gateway/how-it-works.adoc
  79. 75
      docs/modules/ROOT/pages/spring-cloud-gateway/http-timeouts-configuration.adoc
  80. 45
      docs/modules/ROOT/pages/spring-cloud-gateway/httpheadersfilters.adoc
  81. 27
      docs/modules/ROOT/pages/spring-cloud-gateway/reactor-netty-access-logs.adoc
  82. 376
      docs/modules/ROOT/pages/spring-cloud-gateway/request-predicates-factories.adoc
  83. 32
      docs/modules/ROOT/pages/spring-cloud-gateway/route-metadata-configuration.adoc
  84. 16
      docs/modules/ROOT/pages/spring-cloud-gateway/starter.adoc
  85. 36
      docs/modules/ROOT/pages/spring-cloud-gateway/the-discoveryclient-route-definition-locator.adoc
  86. 71
      docs/modules/ROOT/pages/spring-cloud-gateway/tls-and-ssl.adoc
  87. 25
      docs/modules/ROOT/pages/spring-cloud-gateway/troubleshooting.adoc
  88. 156
      docs/modules/ROOT/partials/_configprops.adoc
  89. 11
      docs/modules/ROOT/partials/_conventions.adoc
  90. 46
      docs/modules/ROOT/partials/_metrics.adoc
  91. 29
      docs/modules/ROOT/partials/_spans.adoc
  92. 53
      docs/pom.xml
  93. 20
      docs/src/main/antora/resources/antora-resources/antora.yml
  94. 25
      docs/src/main/asciidoc/README.adoc
  95. 147
      docs/src/main/asciidoc/_configprops.adoc
  96. 1
      docs/src/main/asciidoc/index.adoc
  97. 2813
      docs/src/main/asciidoc/spring-cloud-gateway.adoc
  98. 51
      pom.xml
  99. 22
      spring-cloud-gateway-dependencies/pom.xml
  100. 131
      spring-cloud-gateway-integration-tests/grpc/pom.xml
  101. Some files were not shown because too many files have changed in this diff Show More

44
.circleci/config.yml

@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
version: 2
jobs:
build:
machine: true
# docker:
# - image: springcloud/pipeline-base
environment:
_JAVA_OPTIONS: "-Xms1024m -Xmx2048m"
CACHEVER: 3
TERM: dumb
branches:
ignore:
- gh-pages # list of branches to ignore
steps:
- checkout
- type: shell
name: "Write CACHEVER to file"
command: echo "$CACHEVER" > ~/CACHEVER.txt
- restore_cache:
key: sc-gateway-{{ .Branch }}-{{ checksum "~/CACHEVER.txt" }}
- run:
name: "Download dependencies"
command: |
./mvnw -s .settings.xml -U --fail-never dependency:go-offline || true
- save_cache:
key: sc-gateway-{{ .Branch }}-{{ checksum "~/CACHEVER.txt" }}
paths:
- ~/.m2
- run:
name: "Running build"
command: ./mvnw -s .settings.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- run:
name: "Aggregate test results"
when: always
command: |
mkdir -p ~/junit/
find . -type f -regex ".*/target/.*-reports/.*" -exec cp {} ~/junit/ \;
bash <(curl -s https://codecov.io/bash)
- store_artifacts:
path: ~/junit/
destination: artifacts
- store_test_results:
path: ~/junit/
destination: testartifacts

49
.github/dependabot.yml

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "3.1.x" # oldest OSS supported branch
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "4.0.x" # oldest OSS supported branch
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "main"
schedule:
interval: "weekly"
- package-ecosystem: maven
directory: /
schedule:
interval: daily
target-branch: 3.1.x
ignore:
# only upgrade patch versions for maintenance branch
- dependency-name: "*"
update-types:
- version-update:semver-major
- version-update:semver-minor
- package-ecosystem: maven
directory: /
schedule:
interval: daily
target-branch: 4.0.x
ignore:
# only upgrade patch versions for maintenance branch
- dependency-name: "*"
update-types:
- version-update:semver-major
- version-update:semver-minor
- package-ecosystem: maven
directory: /
schedule:
interval: daily
target-branch: main
ignore:
# only upgrade by minor or patch
- dependency-name: "*"
update-types:
- version-update:semver-major

32
.github/workflows/deploy-docs.yml

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
name: Deploy Docs
on:
push:
branches-ignore: [ gh-pages ]
tags: '**'
repository_dispatch:
types: request-build-reference # legacy
#schedule:
#- cron: '0 10 * * *' # Once per day at 10am UTC
workflow_dispatch:
permissions:
actions: write
jobs:
build:
runs-on: ubuntu-latest
# if: github.repository_owner == 'spring-cloud'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: docs-build
fetch-depth: 1
- name: Dispatch (partial build)
if: github.ref_type == 'branch'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }}
- name: Dispatch (full build)
if: github.ref_type == 'tag'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD)

37
.github/workflows/maven.yml

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Build
on:
push:
branches: [ main, 3.1.x ]
pull_request:
branches: [ main, 3.1.x ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: ./mvnw clean install -B -U -Pspring -Dmaven.test.redirectTestOutputToFile=true -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/surefire-reports/TEST-*.xml'

7
.gitignore vendored

@ -21,4 +21,9 @@ _site/ @@ -21,4 +21,9 @@ _site/
*.swo
.vscode/
.flattened-pom.xml
.sdkmanrc
node
node_modules
build
package.json
package-lock.json

2
.mvn/maven.config

@ -1 +1 @@ @@ -1 +1 @@
-DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring
-P spring

BIN
.mvn/wrapper/maven-wrapper.jar vendored

Binary file not shown.

19
.mvn/wrapper/maven-wrapper.properties vendored

@ -1 +1,18 @@ @@ -1 +1,18 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

3
.sdkmanrc

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=17.0.1-tem

222
README.adoc

@ -5,19 +5,17 @@ Edit the files in the src/main/asciidoc/ directory instead. @@ -5,19 +5,17 @@ Edit the files in the src/main/asciidoc/ directory instead.
////
image::https://circleci.com/gh/spring-cloud/spring-cloud-gateway/tree/master.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-gateway/tree/master"]
image::https://codecov.io/gh/spring-cloud/spring-cloud-gateway/branch/master/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-gateway/branch/master"]
image::https://api.codacy.com/project/badge/Grade/a6885a06921e4f72a0df0b7aabd6d118["Codacy code quality", link="https://www.codacy.com/app/spring-cloud/spring-cloud-gateway?utm_source=github.com&utm_medium=referral&utm_content=spring-cloud/spring-cloud-gateway&utm_campaign=Badge_Grade"]
image::https://github.com/spring-cloud/spring-cloud-gateway/workflows/Build/badge.svg?style=svg["Actions Status", link="https://github.com/spring-cloud/spring-cloud-gateway/actions"]
image::https://codecov.io/gh/spring-cloud/spring-cloud-gateway/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-gateway/branch/main"]
This project provides an API Gateway built on top of the Spring Ecosystem, including: Spring 5, Spring Boot 2 and Project Reactor. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.
[[features]]
= Features
== Features
* Java 8
* Spring Framework 5
* Spring Boot 2
* Java 17
* Spring Framework 6
* Spring Boot 3
* Dynamic routing
* Route matching built into Spring Handler Mapping
* Route matching on HTTP Request (Path, Method, Header, Host, etc...)
@ -26,114 +24,20 @@ This project provides an API Gateway built on top of the Spring Ecosystem, inclu @@ -26,114 +24,20 @@ This project provides an API Gateway built on top of the Spring Ecosystem, inclu
* API or configuration driven
* Supports Spring Cloud `DiscoveryClient` for configuring Routes
== Building
:jdkversion: 1.8
=== Basic Compile and Test
To build the source you will need to install JDK {jdkversion}.
Spring Cloud uses Maven for most build-related activities, and you
should be able to get off the ground quite quickly by cloning the
project you are interested in and typing
----
$ ./mvnw install
----
NOTE: You can also install Maven (>=3.3.3) yourself and run the `mvn` command
in place of `./mvnw` in the examples below. If you do that you also
might need to add `-P spring` if your local Maven settings do not
contain repository declarations for spring pre-release artifacts.
NOTE: Be aware that you might need to increase the amount of memory
available to Maven by setting a `MAVEN_OPTS` environment variable with
a value like `-Xmx512m -XX:MaxPermSize=128m`. We try to cover this in
the `.mvn` configuration, so if you find you have to do it to make a
build succeed, please raise a ticket to get the settings added to
source control.
For hints on how to build the project look in `.travis.yml` if there
is one. There should be a "script" and maybe "install" command. Also
look at the "services" section to see if any services need to be
running locally (e.g. mongo or rabbit). Ignore the git-related bits
that you might find in "before_install" since they're related to setting git
credentials and you already have those.
The projects that require middleware generally include a
`docker-compose.yml`, so consider using
https://docs.docker.com/compose/[Docker Compose] to run the middeware servers
in Docker containers. See the README in the
https://github.com/spring-cloud-samples/scripts[scripts demo
repository] for specific instructions about the common cases of mongo,
rabbit and redis.
NOTE: If all else fails, build with the command from `.travis.yml` (usually
`./mvnw install`).
=== Documentation
The spring-cloud-build module has a "docs" profile, and if you switch
that on it will try to build asciidoc sources from
`src/main/asciidoc`. As part of that process it will look for a
`README.adoc` and process it by loading all the includes, but not
parsing or rendering it, just copying it to `${main.basedir}`
(defaults to `${basedir}`, i.e. the root of the project). If there are
any changes in the README it will then show up after a Maven build as
a modified file in the correct place. Just commit it and push the change.
=== Working with the code
If you don't have an IDE preference we would recommend that you use
https://www.springsource.com/developer/sts[Spring Tools Suite] or
https://eclipse.org[Eclipse] when working with the code. We use the
https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools
should also work without issue as long as they use Maven 3.3.3 or better.
==== Activate the Spring Maven profile
Spring Cloud projects require the 'spring' Maven profile to be activated to resolve
the spring milestone and snapshot repositories. Use your preferred IDE to set this
profile to be active, or you may experience build errors.
==== Importing into eclipse with m2eclipse
We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with
eclipse. If you don't already have m2eclipse installed it is available from the "eclipse
marketplace".
NOTE: Older versions of m2e do not support Maven 3.3, so once the
projects are imported into Eclipse you will also need to tell
m2eclipse to use the right profile for the projects. If you
see many different errors related to the POMs in the projects, check
that you have an up to date installation. If you can't upgrade m2e,
add the "spring" profile to your `settings.xml`. Alternatively you can
copy the repository settings from the "spring" profile of the parent
pom into your `settings.xml`.
==== Importing into eclipse without m2eclipse
If you prefer not to use m2eclipse you can generate eclipse project metadata using the
following command:
[indent=0]
----
$ ./mvnw eclipse:eclipse
----
The generated eclipse projects can be imported by selecting `import existing projects`
from the `file` menu.
== Contributing
[[building]]
= Building
:spring-cloud-build-branch: master
:spring-cloud-build-branch: main
Spring Cloud is released under the non-restrictive Apache 2.0 license,
and follows a very standard Github development process, using Github
tracker for issues and merging pull requests into master. If you want
tracker for issues and merging pull requests into main. If you want
to contribute even something trivial please do not hesitate, but
follow the guidelines below.
=== Sign the Contributor License Agreement
[[sign-the-contributor-license-agreement]]
== Sign the Contributor License Agreement
Before we accept a non-trivial patch or pull request we will need you to sign the
https://cla.pivotal.io/sign/spring[Contributor License Agreement].
Signing the contributor's agreement does not grant anyone commit rights to the main
@ -141,19 +45,21 @@ repository, but it does mean that we can accept your contributions, and you will @@ -141,19 +45,21 @@ repository, but it does mean that we can accept your contributions, and you will
author credit if we do. Active contributors might be asked to join the core team, and
given the ability to merge pull requests.
=== Code of Conduct
This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of
[[code-of-conduct]]
== Code of Conduct
This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/main/docs/src/main/asciidoc/code-of-conduct.adoc[code of
conduct]. By participating, you are expected to uphold this code. Please report
unacceptable behavior to spring-code-of-conduct@pivotal.io.
=== Code Conventions and Housekeeping
[[code-conventions-and-housekeeping]]
== Code Conventions and Housekeeping
None of these is essential for a pull request, but they will all help. They can also be
added after the original pull request but before a merge.
* Use the Spring Framework code format conventions. If you use Eclipse
you can import formatter settings using the
`eclipse-code-formatter.xml` file from the
https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring
https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring
Cloud Build] project. If using IntelliJ, you can use the
https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter
Plugin] to import the same file.
@ -166,13 +72,14 @@ added after the original pull request but before a merge. @@ -166,13 +72,14 @@ added after the original pull request but before a merge.
than cosmetic changes).
* Add some Javadocs and, if you change the namespace, some XSD doc elements.
* A few unit tests would help a lot as well -- someone has to do it.
* If no-one else is using your branch, please rebase it against the current master (or
* If no-one else is using your branch, please rebase it against the current main (or
other target branch in the main project).
* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions],
if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit
message (where XXXX is the issue number).
=== Checkstyle
[[checkstyle]]
== Checkstyle
Spring Cloud Build comes with a set of checkstyle rules. You can find them in the `spring-cloud-build-tools` module. The most notable files under the module are:
@ -190,7 +97,8 @@ Spring Cloud Build comes with a set of checkstyle rules. You can find them in th @@ -190,7 +97,8 @@ Spring Cloud Build comes with a set of checkstyle rules. You can find them in th
<2> File header setup
<3> Default suppression rules
==== Checkstyle configuration
[[checkstyle-configuration]]
=== Checkstyle configuration
Checkstyle rules are *disabled by default*. To add checkstyle to your project just define the following properties and plugins.
@ -249,16 +157,18 @@ If you need to suppress some rules (e.g. line length needs to be longer), then i @@ -249,16 +157,18 @@ If you need to suppress some rules (e.g. line length needs to be longer), then i
It's advisable to copy the `${spring-cloud-build.rootFolder}/.editorconfig` and `${spring-cloud-build.rootFolder}/.springformat` to your project. That way, some default formatting rules will be applied. You can do so by running this script:
```bash
$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig
$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/.editorconfig -o .editorconfig
$ touch .springformat
```
=== IDE setup
[[ide-setup]]
== IDE setup
==== Intellij IDEA
[[intellij-idea]]
=== Intellij IDEA
In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin.
The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project.
The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/main/spring-cloud-build-tools[Spring Cloud Build] project.
.spring-cloud-build-tools/
----
@ -281,13 +191,13 @@ The following files can be found in the https://github.com/spring-cloud/spring-c @@ -281,13 +191,13 @@ The following files can be found in the https://github.com/spring-cloud/spring-c
.Code style
image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style]
image::intellij-code-style.png[Code style]
Go to `File` -> `Settings` -> `Editor` -> `Code style`. There click on the icon next to the `Scheme` section. There, click on the `Import Scheme` value and pick the `Intellij IDEA code style XML` option. Import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml` file.
.Inspection profiles
image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style]
image::intellij-inspections.png[Code style]
Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon next to the `Profile` section. There, click on the `Import Profile` and import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml` file.
@ -295,12 +205,70 @@ Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon @@ -295,12 +205,70 @@ Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon
To have Intellij work with Checkstyle, you have to install the `Checkstyle` plugin. It's advisable to also install the `Assertions2Assertj` to automatically convert the JUnit assertions
image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle]
image::intellij-checkstyle.png[Checkstyle]
Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables:
Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables:
- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL.
- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL.
- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL.
- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL.
- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`.
IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources.
[[duplicate-finder]]
== Duplicate Finder
Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath.
[[duplicate-finder-configuration]]
=== Duplicate Finder configuration
Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`.
.pom.xml
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
----
For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation].
You can easily override them but setting the value of the selected property prefixed with `duplicate-finder-maven-plugin`. For example, set `duplicate-finder-maven-plugin.skip` to `true` in order to skip duplicates check in your build.
If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project:
[source,xml]
----
<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<configuration>
<ignoredClassPatterns>
<ignoredClassPattern>org.joda.time.base.BaseDateTime</ignoredClassPattern>
<ignoredClassPattern>.*module-info</ignoredClassPattern>
</ignoredClassPatterns>
<ignoredResourcePatterns>
<ignoredResourcePattern>changelog.txt</ignoredResourcePattern>
</ignoredResourcePatterns>
</configuration>
</plugin>
</plugins>
</build>
----
[[contributing]]
= Contributing
Unresolved directive in <stdin> - include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/contributing.adoc[]

36
circle-v1.yml

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
general:
branches:
ignore:
- gh-pages # list of branches to ignore
machine:
services:
- redis
java:
version: oraclejdk8
environment:
_JAVA_OPTIONS: "-Xms1024m -Xmx2048m"
# TEST_HOSTPORT: localhost:5000
dependencies:
pre:
# - sudo apt-get update; sudo apt-get install python-httpbin
# - pip install httpbin
override:
- ./mvnw -s .settings.xml -U --fail-never dependency:go-offline || true
test:
pre:
# - python -m httpbin.core:
# background: true
# - sleep 3
override:
- ./mvnw -s .settings.xml clean install org.jacoco:jacoco-maven-plugin:prepare-agent install -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
post:
- find . -type f -regex ".*/spring-cloud-*.*/target/*.*" | cpio -pdm $CIRCLE_ARTIFACTS
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find . -type f -regex ".*/target/.*-reports/.*" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
- bash <(curl -s https://codecov.io/bash)
notify:
webhooks:
# A list of hook hashes, containing the url field
# gitter hook
- url: https://webhooks.gitter.im/e/22e6bb4eb945dd61ba54

39
docs/antora-playbook.yml

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
antora:
extensions:
- '@springio/antora-extensions/partial-build-extension'
- require: '@springio/antora-extensions/latest-version-extension'
- require: '@springio/antora-extensions/inject-collector-cache-config-extension'
- '@antora/collector-extension'
- '@antora/atlas-extension'
- require: '@springio/antora-extensions/root-component-extension'
root_component_name: 'cloud-gateway'
- '@springio/antora-extensions/static-page-extension'
site:
title: Spring Cloud Gateway
url: https://docs.spring.io/spring-cloud-gateway/reference/
content:
sources:
- url: ./..
branches: HEAD
start_path: docs
worktrees: true
asciidoc:
attributes:
page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud
page-pagination: ''
hide-uri-scheme: '@'
tabs-sync-option: '@'
chomp: 'all'
extensions:
- '@asciidoctor/tabs'
- '@springio/asciidoctor-extensions'
sourcemap: true
urls:
latest_version_segment: ''
runtime:
log:
failure_level: warn
format: pretty
ui:
bundle:
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.2/ui-bundle.zip

12
docs/antora.yml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
name: cloud-gateway
version: true
title: Spring Cloud Gateway
nav:
- modules/ROOT/nav.adoc
ext:
collector:
run:
command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests
local: true
scan:
dir: ./target/classes/antora-resources/

BIN
docs/modules/ROOT/assets/images/gateway-grafana-dashboard.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

BIN
docs/modules/ROOT/assets/images/spring_cloud_gateway_diagram.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

77
docs/modules/ROOT/nav.adoc

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
* xref:index.adoc[Introduction]
// begin Gateway Reactive Server
* xref:spring-cloud-gateway.adoc[]
** xref:spring-cloud-gateway/starter.adoc[]
** xref:spring-cloud-gateway/glossary.adoc[]
** xref:spring-cloud-gateway/how-it-works.adoc[]
** xref:spring-cloud-gateway/configuring-route-predicate-factories-and-filter-factories.adoc[]
** xref:spring-cloud-gateway/request-predicates-factories.adoc[]
** xref:spring-cloud-gateway/gatewayfilter-factories.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/addrequestheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/addrequestheadersifnotpresent-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/addrequestparameter-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/addresponseheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/circuitbreaker-filter-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/cacherequestbody-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/deduperesponseheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/fallback-headers.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/jsontogrpc-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/local-cache-response-filter.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/maprequestheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/modifyrequestbody-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/modifyresponsebody-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/prefixpath-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/preservehostheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/redirectto-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/removejsonattributesresponsebody-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/removerequestheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/removerequestparameter-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/removeresponseheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/requestheadersize-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/requestratelimiter-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/rewritelocationresponseheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/rewritepath-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/rewriterequestparameter-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/rewriteresponseheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/savesession-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/secureheaders-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/setpath-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/setrequestheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/setresponseheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/setstatus-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/stripprefix-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/retry-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/requestsize-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/setrequesthostheader-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/tokenrelay-factory.adoc[]
*** xref:spring-cloud-gateway/gatewayfilter-factories/default-filters.adoc[]
** xref:spring-cloud-gateway/global-filters.adoc[]
** xref:spring-cloud-gateway/httpheadersfilters.adoc[]
** xref:spring-cloud-gateway/tls-and-ssl.adoc[]
** xref:spring-cloud-gateway/configuration.adoc[]
** xref:spring-cloud-gateway/route-metadata-configuration.adoc[]
** xref:spring-cloud-gateway/http-timeouts-configuration.adoc[]
** xref:spring-cloud-gateway/fluent-java-routes-api.adoc[]
** xref:spring-cloud-gateway/the-discoveryclient-route-definition-locator.adoc[]
** xref:spring-cloud-gateway/reactor-netty-access-logs.adoc[]
** xref:spring-cloud-gateway/cors-configuration.adoc[]
** xref:spring-cloud-gateway/actuator-api.adoc[]
** xref:spring-cloud-gateway/troubleshooting.adoc[]
** xref:spring-cloud-gateway/developer-guide.adoc[]
** xref:spring-cloud-gateway/aot-and-native-image-support.adoc[]
** xref:spring-cloud-gateway/configuration-properties.adoc[]
// begin Gateway Server MVC
* xref:spring-cloud-gateway-server-mvc.adoc[]
** xref:spring-cloud-gateway-server-mvc/starter.adoc[]
** xref:spring-cloud-gateway-server-mvc/glossary.adoc[]
** xref:spring-cloud-gateway-server-mvc/how-it-works.adoc[]
** xref:spring-cloud-gateway-server-mvc/java-routes-api.adoc[]
// begin Gateway Proxy Exchange
* xref:spring-cloud-gateway-proxy-exchange.adoc[]
* xref:appendix.adoc[]

2
docs/src/main/asciidoc/_attributes.adoc → docs/modules/ROOT/pages/_attributes.adoc

@ -1,8 +1,6 @@ @@ -1,8 +1,6 @@
:doctype: book
:idprefix:
:idseparator: -
:toc: left
:toclevels: 4
:tabsize: 4
:numbered:
:sectanchors:

17
docs/src/main/asciidoc/appendix.adoc → docs/modules/ROOT/pages/appendix.adoc

@ -1,14 +1,23 @@ @@ -1,14 +1,23 @@
:numbered!:
[appendix]
[[common-application-properties]]
== Common application properties
= Common application properties
:page-section-summary-toc: 1
include::_attributes.adoc[]
Various properties can be specified inside your `application.properties` file, inside your `application.yml` file, or as command line switches.
This appendix provides a list of common {project-full-name} properties and references to the underlying classes that consume them.
This appendix provides a list of common Spring Cloud Gateway properties and references to the underlying classes that consume them.
NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list.
Also, you can define your own properties.
include::_configprops.adoc[]
include::partial$_configprops.adoc[]
[[observability]]
== Observability metadata
include::partial$_metrics.adoc[]
include::partial$_spans.adoc[]
include::partial$_conventions.adoc[]

6
docs/modules/ROOT/pages/configprops.adoc

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[[configuration-properties]]
= Configuration Properties
Below you can find a list of configuration properties.
include::partial$_configprops.adoc[]

1
docs/modules/ROOT/pages/index.adoc

@ -0,0 +1 @@ @@ -0,0 +1 @@
include::intro.adoc[]

6
docs/src/main/asciidoc/intro.adoc → docs/modules/ROOT/pages/intro.adoc

@ -1,2 +1,6 @@ @@ -1,2 +1,6 @@
This project provides an API Gateway built on top of the Spring Ecosystem, including: Spring 5, Spring Boot 2 and Project Reactor. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.
[[introduction]]
= Spring Cloud Gateway
// TODO: docs, rework intro for 4 modules
This project provides an API Gateway built on top of the Spring Ecosystem, including: Spring 6, Spring Boot 3 and Project Reactor. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.

72
docs/modules/ROOT/pages/spring-cloud-gateway-proxy-exchange.adoc

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
[[proxy-exchange-gateway]]
= Proxy Exchange Gateway with Spring MVC or Webflux
WARNING: The following describes an alternative style gateway. None of the Spring Cloud Gateway Server documentation applies to what follows.
Spring Cloud Gateway provides a utility object called `ProxyExchange`.
You can use it inside a regular Spring web handler as a method parameter.
It supports basic downstream HTTP exchanges through methods that mirror the HTTP verbs.
With MVC, it also supports forwarding to a local handler through the `forward()` method.
To use the `ProxyExchange`, include the right module in your classpath (either `spring-cloud-gateway-mvc` or `spring-cloud-gateway-webflux`).
The following MVC example proxies a request to `/test` downstream to a remote server:
[source,java]
----
@RestController
@SpringBootApplication
public class GatewaySampleApplication {
@Value("${remote.home}")
private URI home;
@GetMapping("/test")
public ResponseEntity<?> proxy(ProxyExchange<byte[]> proxy) throws Exception {
return proxy.uri(home.toString() + "/image/png").get();
}
}
----
The following example does the same thing with Webflux:
[source,java]
----
@RestController
@SpringBootApplication
public class GatewaySampleApplication {
@Value("${remote.home}")
private URI home;
@GetMapping("/test")
public Mono<ResponseEntity<?>> proxy(ProxyExchange<byte[]> proxy) throws Exception {
return proxy.uri(home.toString() + "/image/png").get();
}
}
----
Convenience methods on the `ProxyExchange` enable the handler method to discover and enhance the URI path of the incoming request.
For example, you might want to extract the trailing elements of a path to pass them downstream:
[source,java]
----
@GetMapping("/proxy/path/**")
public ResponseEntity<?> proxyPath(ProxyExchange<byte[]> proxy) throws Exception {
String path = proxy.path("/proxy/path/");
return proxy.uri(home.toString() + "/foos/" + path).get();
}
----
All the features of Spring MVC and Webflux are available to gateway handler methods.
As a result, you can inject request headers and query parameters, for instance, and you can constrain the incoming requests with declarations in the mapping annotation.
See the documentation for `@RequestMapping` in Spring MVC for more details of those features.
You can add headers to the downstream response by using the `header()` methods on `ProxyExchange`.
You can also manipulate response headers (and anything else you like in the response) by adding a mapper to the `get()` method (and other methods).
The mapper is a `Function` that takes the incoming `ResponseEntity` and converts it to an outgoing one.
First-class support is provided for "`sensitive`" headers (by default, `cookie` and `authorization`), which are not passed downstream, and for "`proxy`" (`x-forwarded-*`) headers.

5
docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc.adoc

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
[[spring-cloud-gateway-server-mvc]]
= Spring Cloud Gateway Server MVC
:page-section-summary-toc: 1
// TODO:

11
docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/glossary.adoc

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
[[glossary]]
= Glossary
:page-section-summary-toc: 1
* *Route*: The basic building block of the gateway.
It is defined by an ID, a destination URI, a collection of predicates, and a collection of filters. A route is matched if the aggregate predicate is true.
* *Predicate*: This is a https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/RequestPredicate.html[Spring WebMvc.fn `RequestPredicate`]. The input type is a https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/ServerRequest.html[Spring WebMvc.fn `ServerRequest`].
This lets you match on anything from the HTTP request, such as headers or parameters.
* *Filter*: These are instances of https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/HandlerFilterFunction.html[`HandlerFilterFunction`].
Here, you can modify requests and responses before or after sending the downstream request. Filters may also implement `Function<ServerRequest, ServerRequest>` and adapted to a `HandlerFilterFunction` by https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/HandlerFilterFunction.html#ofRequestProcessor(java.util.function.Function)[`HandlerFilterFunction.ofRequestProcessor()`] for 'before' filters. For 'after' filters, `BiFunction<ServerRequest,T extends ServerResponse,R extends ServerResponse>` may be implemented and adapted by https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/HandlerFilterFunction.html#ofResponseProcessor(java.util.function.BiFunction)[`HandlerFilterFunction.ofResponseProcessor()`].

17
docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/how-it-works.adoc

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
[[gateway-how-it-works]]
= How It Works
:page-section-summary-toc: 1
The following diagram provides a high-level overview of how Spring Cloud Gateway works:
// TODO: gateway mvc diagram
//image::spring_cloud_gateway_diagram.png[Spring Cloud Gateway Diagram]
In Spring Cloud Gateway Server MVC routes are normal WebMvc.fn `RouterFunction` instances with a special https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/HandlerFunction.html[HandlerFunction] to forward the requests over HTTP defined in https://github.com/spring-cloud/spring-cloud-gateway/blob/main/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/handler/HandlerFunctions.java[org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions]. Please see the https://docs.spring.io/spring-framework/reference/web/webmvc-functional.html[WebMvc.fn] documentation for regular use of the functional API.
In addition to custom `HandlerFunctions` for HTTP forwarding, Spring Cloud Gateway Server MVC provides additional `RequestPredicate` implementations in https://github.com/spring-cloud/spring-cloud-gateway/blob/main/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/predicate/GatewayRequestPredicates.java[org.springframework.cloud.gateway.server.mvc.predicate.GatewayRequestPredicates] and `HandlerFilterFunctions` implementations in https://github.com/spring-cloud/spring-cloud-gateway/blob/main/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/FilterFunctions.java[org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions]. All the custom filters that can be pure 'before' filters are implemented in https://github.com/spring-cloud/spring-cloud-gateway/blob/main/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/BeforeFilterFunctions.java[org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions] and adapted in `FilterFunctions` as request processors. The custom 'after' filters in https://github.com/spring-cloud/spring-cloud-gateway/blob/main/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/AfterFilterFunctions.java[org.springframework.cloud.gateway.server.mvc.filter.AfterFilterFunctions] are also adapted in `FilterFunctions` as response processors.
There are additional `*FilterFunctions` classes for optional filters that will are documented along with each filter.

41
docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/java-routes-api.adoc

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
[[java-routes-api]]
= Java Routes API
Spring Cloud Gateway Server MVC uses the Spring WebMvc.fn https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/RouterFunctions.Builder.html[RouterFunctions.Builder] as the default way to create Routes, which are WebMvc.fn https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/RouterFunction.html[RouterFunction] instances.
A https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/RouterFunctions.Builder.html[`RouterFunctions.Builder`] instance is obtained by calling https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/function/RouterFunctions.html#route()[RouterFunctions.route()]
.GatewaySampleApplication.java
[source,java]
----
import org.springframework.web.servlet.function.RouterFunctions.route;
import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http;
class SimpleGateway {
@Bean
public RouterFunction<ServerResponse> getRoute() {
return route().GET("/get", http("https://httpbin.org"));
}
}
----
There are methods in `RouterFunctions.Builder` for each HTTP methods (GET, POST, etc...) combined with a path predicate, such as `/get` as above. The final parameter is the `HandlerFilterFunction`, in this case `HandlerFunctions.http()`. There are overloaded methods for each HTTP method for additional `RequestPredicate` parameters as well as a generic `route(RequestPredicate, HandlerFunction`) method for general use.
[[gateway-routerfunctions-builder]]
== Gateway MVC implementation of RouterFunctions.Builder
Some advanced filters require some metadata to be added to request attributes. To accommodate this, there is a `org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions` class. `GatewayRouterFunctions.route(String routeId) creates a `RouterFunctions.Builder` instance then adds a 'before' filter to add the `routeId` as request metadata.
.GatewaySampleApplication.java
[source,java]
----
import org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions;
import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http;
class SimpleGateway {
@Bean
public RouterFunction<ServerResponse> getRoute() {
return route("simple_route").GET("/get", http("https://httpbin.org"));
}
}
----

14
docs/modules/ROOT/pages/spring-cloud-gateway-server-mvc/starter.adoc

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
[[gateway-starter]]
= How to Include Spring Cloud Gateway Server MVC
:page-section-summary-toc: 1
To include Spring Cloud Gateway Server MVC in your project, use the starter with a group ID of `org.springframework.cloud` and an artifact ID of `spring-cloud-starter-gateway-mvc`.
See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train.
If you include the starter, but you do not want the gateway to be enabled, set `spring.cloud.gateway.mvc.enabled=false`.
IMPORTANT: Spring Cloud Gateway Server MVC is built on https://spring.io/projects/spring-boot#learn[Spring Boot] and https://docs.spring.io/spring-framework/reference/web/webmvc-functional.html[Spring WebMvc.fn].
As a consequence, many of the asynchronous or reactive libraries may not apply when you use Spring Cloud Gateway Server MVC.
IMPORTANT: Spring Cloud Gateway Server MVC works with traditional Servlet runtimes such as Tomcat and Jetty.

7
docs/modules/ROOT/pages/spring-cloud-gateway.adoc

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
[[spring-cloud-gateway]]
= Spring Cloud Gateway Reactive Server
:page-section-summary-toc: 1
*{spring-cloud-version}*

291
docs/modules/ROOT/pages/spring-cloud-gateway/actuator-api.adoc

@ -0,0 +1,291 @@ @@ -0,0 +1,291 @@
[[actuator-api]]
= Actuator API
The `/gateway` actuator endpoint lets you monitor and interact with a Spring Cloud Gateway application.
To be remotely accessible, the endpoint has to be https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-endpoints-enabling-endpoints[enabled] and https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-endpoints-exposing-endpoints[exposed over HTTP or JMX] in the application properties.
The following listing shows how to do so:
.application.properties
[source,properties]
----
management.endpoint.gateway.enabled=true # default value
management.endpoints.web.exposure.include=gateway
----
[[verbose-actuator-format]]
== Verbose Actuator Format
A new, more verbose format has been added to Spring Cloud Gateway.
It adds more detail to each route, letting you view the predicates and filters associated with each route along with any configuration that is available.
The following example configures `/actuator/gateway/routes`:
[source,json]
----
[
{
"predicate": "(Hosts: [**.addrequestheader.org] && Paths: [/headers], match trailing slash: true)",
"route_id": "add_request_header_test",
"filters": [
"[[AddResponseHeader X-Response-Default-Foo = 'Default-Bar'], order = 1]",
"[[AddRequestHeader X-Request-Foo = 'Bar'], order = 1]",
"[[PrefixPath prefix = '/httpbin'], order = 2]"
],
"uri": "lb://testservice",
"order": 0
}
]
----
This feature is enabled by default. To disable it, set the following property:
.application.properties
[source,properties]
----
spring.cloud.gateway.actuator.verbose.enabled=false
----
This will default to `true` in a future release.
[[retrieving-route-filters]]
== Retrieving Route Filters
This section details how to retrieve route filters, including:
* xref:spring-cloud-gateway/actuator-api.adoc#gateway-global-filters[Global Filters]
* <<gateway-route-filters>>
[[gateway-global-filters]]
=== Global Filters
To retrieve the xref:spring-cloud-gateway/global-filters.adoc[global filters] applied to all routes, make a `GET` request to `/actuator/gateway/globalfilters`. The resulting response is similar to the following:
----
{
"org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter@77856cc5": 10100,
"org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@4f6fd101": 10000,
"org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@32d22650": -1,
"org.springframework.cloud.gateway.filter.ForwardRoutingFilter@106459d9": 2147483647,
"org.springframework.cloud.gateway.filter.NettyRoutingFilter@1fbd5e0": 2147483647,
"org.springframework.cloud.gateway.filter.ForwardPathFilter@33a71d23": 0,
"org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@135064ea": 2147483637,
"org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@23c05889": 2147483646
}
----
The response contains the details of the global filters that are in place.
For each global filter, there is a string representation of the filter object (for example, `org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter@77856cc5`) and the corresponding xref:spring-cloud-gateway/global-filters.adoc#gateway-combined-global-filter-and-gatewayfilter-ordering[order] in the filter chain.
[[gateway-route-filters]]
=== Route Filters
To retrieve the xref:spring-cloud-gateway/gatewayfilter-factories.adoc[`GatewayFilter` factories] applied to routes, make a `GET` request to `/actuator/gateway/routefilters`.
The resulting response is similar to the following:
----
{
"[AddRequestHeaderGatewayFilterFactory@570ed9c configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
"[SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]": null,
"[SaveSessionGatewayFilterFactory@4449b273 configClass = Object]": null
}
----
The response contains the details of the `GatewayFilter` factories applied to any particular route.
For each factory there is a string representation of the corresponding object (for example, `[SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]`).
Note that the `null` value is due to an incomplete implementation of the endpoint controller, because it tries to set the order of the object in the filter chain, which does not apply to a `GatewayFilter` factory object.
[[refreshing-the-route-cache]]
== Refreshing the Route Cache
To clear the routes cache, make a `POST` request to `/actuator/gateway/refresh`.
The request returns a 200 without a response body.
To clear the routes with specific metadata values, add the Query parameter `metadata` specifying the `key:value` pairs that the routes to be cleared should match.
If an error is produced during the asynchronous refresh, the refresh will not modify the existing routes.
Sending `POST` request to `/actuator/gateway/refresh?metadata=group:group-1` will only refresh the routes whose `group` metadata is `group-1`: `first_route` and `third_route`.
[source,json]
----
[{
"route_id": "first_route",
"route_object": {
"predicate": "...",
},
"metadata": { "group": "group-1" }
},
{
"route_id": "second_route",
"route_object": {
"predicate": "...",
},
"metadata": { "group": "group-2" }
},
{
"route_id": "third_route",
"route_object": {
"predicate": "...",
},
"metadata": { "group": "group-1" }
}]
----
[[retrieving-the-routes-defined-in-the-gateway]]
== Retrieving the Routes Defined in the Gateway
To retrieve the routes defined in the gateway, make a `GET` request to `/actuator/gateway/routes`.
The resulting response is similar to the following:
----
[{
"route_id": "first_route",
"route_object": {
"predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@1e9d7e7d",
"filters": [
"OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.PreserveHostHeaderGatewayFilterFactory$$Lambda$436/674480275@6631ef72, order=0}"
]
},
"order": 0
},
{
"route_id": "second_route",
"route_object": {
"predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@cd8d298",
"filters": []
},
"order": 0
}]
----
The response contains the details of all the routes defined in the gateway.
The following table describes the structure of each element (each is a route) of the response:
[cols="3,2,4"]
|===
| Path | Type | Description
|`route_id`
| String
| The route ID.
|`route_object.predicate`
| Object
| The route predicate.
|`route_object.filters`
| Array
| The xref:spring-cloud-gateway/gatewayfilter-factories.adoc[`GatewayFilter` factories] applied to the route.
|`order`
| Number
| The route order.
|===
[[gateway-retrieving-information-about-a-particular-route]]
== Retrieving Information about a Particular Route
To retrieve information about a single route, make a `GET` request to `/actuator/gateway/routes/\{id}` (for example, `/actuator/gateway/routes/first_route`).
The resulting response is similar to the following:
----
{
"id": "first_route",
"predicates": [{
"name": "Path",
"args": {"_genkey_0":"/first"}
}],
"filters": [],
"uri": "https://www.uri-destination.org",
"order": 0
}
----
The following table describes the structure of the response:
[cols="3,2,4"]
|===
| Path | Type | Description
|`id`
| String
| The route ID.
|`predicates`
| Array
| The collection of route predicates. Each item defines the name and the arguments of a given predicate.
|`filters`
| Array
| The collection of filters applied to the route.
|`uri`
| String
| The destination URI of the route.
|`order`
| Number
| The route order.
|===
[[creating-and-deleting-a-particular-route-definition]]
== Creating and Deleting a Particular Route Definition
To create a route definition, make a `POST` request to `/gateway/routes/\{id_route_to_create}` with a JSON body that specifies the fields of the route (see xref:spring-cloud-gateway/actuator-api.adoc#gateway-retrieving-information-about-a-particular-route[Retrieving Information about a Particular Route]).
To delete a route definition, make a `DELETE` request to `/gateway/routes/\{id_route_to_delete}`.
[[creating-multiple-route-definitions]]
== Creating multiple Route Definitions
To create multiple route definitions in a single request, make a `POST` request to `/gateway/routes` with a JSON body that specifies the fields of the route, including the route id (see xref:spring-cloud-gateway/actuator-api.adoc#gateway-retrieving-information-about-a-particular-route[Retrieving Information about a Particular Route]).
The route definitions will be discarded if any route raises an error during the creation of the routes.
[[recap:-the-list-of-all-endpoints]]
== Recap: The List of All endpoints
The following table below summarizes the Spring Cloud Gateway actuator endpoints (note that each endpoint has `/actuator/gateway` as the base-path):
[cols="2,2,5"]
|===
| ID | HTTP Method | Description
|`globalfilters`
|GET
| Displays the list of global filters applied to the routes.
|`routefilters`
|GET
| Displays the list of `GatewayFilter` factories applied to a particular route.
|`refresh`
|POST
| Clears the routes cache.
|`routes`
|GET
| Displays the list of routes defined in the gateway.
|`routes/\{id}`
|GET
| Displays information about a particular route.
|`routes/\{id}`
|POST
| Adds a new route to the gateway.
|`routes/\{id}`
|DELETE
| Removes an existing route from the gateway.
|===
[[sharing-routes-between-multiple-gateway-instances]]
== Sharing Routes between multiple Gateway instances
Spring Cloud Gateway offers two `RouteDefinitionRepository` implementations. The first one is the
`InMemoryRouteDefinitionRepository` which only lives within the memory of one Gateway instance.
This type of Repository is not suited to populate Routes across multiple Gateway instances.
In order to share Routes across a cluster of Spring Cloud Gateway instances, `RedisRouteDefinitionRepository` can be used.
To enable this kind of repository, the following property has to set to true: `spring.cloud.gateway.redis-route-definition-repository.enabled`
Likewise to the RedisRateLimiter Filter Factory it requires the use of the spring-boot-starter-data-redis-reactive Spring Boot starter.

8
docs/modules/ROOT/pages/spring-cloud-gateway/aot-and-native-image-support.adoc

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
[[aot-and-native-image-support]]
= AOT and Native Image Support
:page-section-summary-toc: 1
Since `4.0.0`, Spring Cloud Gateway supports Spring AOT transformations and native images.
TIP: If you're using load-balanced routes, you need to explicitly define your `LoadBalancerClient` service IDs. You can do so by using the `value` or `name` attributes of the `@LoadBalancerClient` annotation or as values of the `spring.cloud.loadbalancer.eager-load.clients` property.

5
docs/modules/ROOT/pages/spring-cloud-gateway/configuration-properties.adoc

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
[[configuration-properties]]
= Configuration properties
:page-section-summary-toc: 1
To see the list of all Spring Cloud Gateway related configuration properties, see link:appendix.html[the appendix].

45
docs/modules/ROOT/pages/spring-cloud-gateway/configuration.adoc

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
[[configuration]]
= Configuration
Configuration for Spring Cloud Gateway is driven by a collection of `RouteDefinitionLocator` instances.
The following listing shows the definition of the `RouteDefinitionLocator` interface:
.RouteDefinitionLocator.java
[source,java]
----
public interface RouteDefinitionLocator {
Flux<RouteDefinition> getRouteDefinitions();
}
----
By default, a `PropertiesRouteDefinitionLocator` loads properties by using Spring Boot's `@ConfigurationProperties` mechanism.
The earlier configuration examples all use a shortcut notation that uses positional arguments rather than named ones.
The following two examples are equivalent:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: setstatus_route
uri: https://example.org
filters:
- name: SetStatus
args:
status: 401
- id: setstatusshortcut_route
uri: https://example.org
filters:
- SetStatus=401
----
For some usages of the gateway, properties are adequate, but some production use cases benefit from loading configuration from an external source, such as a database. Future milestone versions will have `RouteDefinitionLocator` implementations based off of Spring Data Repositories, such as Redis, MongoDB, and Cassandra.
[[routedefinition-metrics]]
== RouteDefinition Metrics
To enable `RouteDefinition` metrics, add spring-boot-starter-actuator as a project dependency. Then, by default, the metrics will be available as long as the property `spring.cloud.gateway.metrics.enabled` is set to `true`. A gauge metric named `spring.cloud.gateway.routes.count` will be added, whose value is the number of `RouteDefinitions`. This metric will be available from `/actuator/metrics/spring.cloud.gateway.routes.count`.

50
docs/modules/ROOT/pages/spring-cloud-gateway/configuring-route-predicate-factories-and-filter-factories.adoc

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
[[configuring-route-predicate-factories-and-gateway-filter-factories]]
= Configuring Route Predicate Factories and Gateway Filter Factories
There are two ways to configure predicates and filters: shortcuts and fully expanded arguments. Most examples below use the shortcut way.
The name and argument names are listed as `code` in the first sentence or two of each section. The arguments are typically listed in the order that are needed for the shortcut configuration.
[[shortcut-configuration]]
== Shortcut Configuration
Shortcut configuration is recognized by the filter name, followed by an equals sign (`=`), followed by argument values separated by commas (`,`).
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
- Cookie=mycookie,mycookievalue
----
The previous sample defines the `Cookie` Route Predicate Factory with two arguments, the cookie name, `mycookie` and the value to match `mycookievalue`.
[[fully-expanded-arguments]]
== Fully Expanded Arguments
Fully expanded arguments appear more like standard yaml configuration with name/value pairs. Typically, there will be a `name` key and an `args` key. The `args` key is a map of key value pairs to configure the predicate or filter.
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
- name: Cookie
args:
name: mycookie
regexp: mycookievalue
----
This is the full configuration of the shortcut configuration of the `Cookie` predicate shown above.

61
docs/modules/ROOT/pages/spring-cloud-gateway/cors-configuration.adoc

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
[[cors-configuration]]
= CORS Configuration
:cors-configuration-docs-uri: https://docs.spring.io/spring/docs/5.0.x/javadoc-api/org/springframework/web/cors/CorsConfiguration.html
You can configure the gateway to control CORS behavior globally or per route.
Both offer the same possibilities.
[[global-cors-configuration]]
== Global CORS Configuration
The "`global`" CORS configuration is a map of URL patterns to {cors-configuration-docs-uri}[Spring Framework `CorsConfiguration`].
The following example configures CORS:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "https://docs.spring.io"
allowedMethods:
- GET
----
In the preceding example, CORS requests are allowed from requests that originate from `docs.spring.io` for all GET requested paths.
To provide the same CORS configuration to requests that are not handled by some gateway route predicate, set the `spring.cloud.gateway.globalcors.add-to-simple-url-handler-mapping` property to `true`.
This is useful when you try to support CORS preflight requests and your route predicate does not evaluate to `true` because the HTTP method is `options`.
[[route-cors-configuration]]
== Route CORS Configuration
The "`route`" configuration allows applying CORS directly to a route as metadata with key `cors`.
Like in the case of global configuration, the properties belong to {cors-configuration-docs-uri}[Spring Framework `CorsConfiguration`].
NOTE: If no `Path` predicate is present in the route '/**' will be applied.
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: cors_route
uri: https://example.org
predicates:
- Path=/service/**
metadata:
cors
allowedOrigins: '*'
allowedMethods:
- GET
- POST
allowedHeaders: '*'
maxAge: 30
----

156
docs/modules/ROOT/pages/spring-cloud-gateway/developer-guide.adoc

@ -0,0 +1,156 @@ @@ -0,0 +1,156 @@
[[developer-guide]]
= Developer Guide
These are basic guides to writing some custom components of the gateway.
[[writing-custom-route-predicate-factories]]
== Writing Custom Route Predicate Factories
In order to write a Route Predicate you will need to implement `RoutePredicateFactory` as a bean. There is an abstract class called `AbstractRoutePredicateFactory` which you can extend.
.MyRoutePredicateFactory.java
[source,java]
----
@Component
public class MyRoutePredicateFactory extends AbstractRoutePredicateFactory<MyRoutePredicateFactory.Config> {
public MyRoutePredicateFactory() {
super(Config.class);
}
@Override
public Predicate<ServerWebExchange> apply(Config config) {
// grab configuration from Config object
return exchange -> {
//grab the request
ServerHttpRequest request = exchange.getRequest();
//take information from the request to see if it
//matches configuration.
return matches(config, request);
};
}
public static class Config {
//Put the configuration properties for your filter here
}
}
----
[[writing-custom-gatewayfilter-factories]]
== Writing Custom GatewayFilter Factories
To write a `GatewayFilter`, you must implement `GatewayFilterFactory` as a bean.
You can extend an abstract class called `AbstractGatewayFilterFactory`.
The following examples show how to do so:
.PreGatewayFilterFactory.java
====
[source,java]
----
@Component
public class PreGatewayFilterFactory extends AbstractGatewayFilterFactory<PreGatewayFilterFactory.Config> {
public PreGatewayFilterFactory() {
super(Config.class);
}
@Override
public GatewayFilter apply(Config config) {
// grab configuration from Config object
return (exchange, chain) -> {
//If you want to build a "pre" filter you need to manipulate the
//request before calling chain.filter
ServerHttpRequest.Builder builder = exchange.getRequest().mutate();
//use builder to manipulate the request
return chain.filter(exchange.mutate().request(builder.build()).build());
};
}
public static class Config {
//Put the configuration properties for your filter here
}
}
----
.PostGatewayFilterFactory.java
[source,java]
----
@Component
public class PostGatewayFilterFactory extends AbstractGatewayFilterFactory<PostGatewayFilterFactory.Config> {
public PostGatewayFilterFactory() {
super(Config.class);
}
@Override
public GatewayFilter apply(Config config) {
// grab configuration from Config object
return (exchange, chain) -> {
return chain.filter(exchange).then(Mono.fromRunnable(() -> {
ServerHttpResponse response = exchange.getResponse();
//Manipulate the response in some way
}));
};
}
public static class Config {
//Put the configuration properties for your filter here
}
}
----
====
[[naming-custom-filters-and-references-in-configuration]]
=== Naming Custom Filters And References In Configuration
Custom filters class names should end in `GatewayFilterFactory`.
For example, to reference a filter named `Something` in configuration files, the filter
must be in a class named `SomethingGatewayFilterFactory`.
WARNING: It is possible to create a gateway filter named without the
`GatewayFilterFactory` suffix, such as `class AnotherThing`. This filter could be
referenced as `AnotherThing` in configuration files. This is **not** a supported naming
convention and this syntax may be removed in future releases. Please update the filter
name to be compliant.
[[writing-custom-global-filters]]
== Writing Custom Global Filters
To write a custom global filter, you must implement `GlobalFilter` interface as a bean.
This applies the filter to all requests.
The following examples show how to set up global pre- and post-filters, respectively:
[source,java]
----
@Bean
public GlobalFilter customGlobalFilter() {
return (exchange, chain) -> exchange.getPrincipal()
.map(Principal::getName)
.defaultIfEmpty("Default User")
.map(userName -> {
//adds header to proxied request
exchange.getRequest().mutate().header("CUSTOM-REQUEST-HEADER", userName).build();
return exchange;
})
.flatMap(chain::filter);
}
@Bean
public GlobalFilter customGlobalPostFilter() {
return (exchange, chain) -> chain.filter(exchange)
.then(Mono.just(exchange))
.map(serverWebExchange -> {
//adds header to response
serverWebExchange.getResponse().getHeaders().set("CUSTOM-RESPONSE-HEADER",
HttpStatus.OK.equals(serverWebExchange.getResponse().getStatusCode()) ? "It worked": "It did not work");
return serverWebExchange;
})
.then();
}
----

41
docs/modules/ROOT/pages/spring-cloud-gateway/fluent-java-routes-api.adoc

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
[[fluent-java-routes-api]]
= Fluent Java Routes API
To allow for simple configuration in Java, the `RouteLocatorBuilder` bean includes a fluent API.
The following listing shows how it works:
.GatewaySampleApplication.java
[source,java]
----
// static imports from GatewayFilters and RoutePredicates
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder, ThrottleGatewayFilterFactory throttle) {
return builder.routes()
.route(r -> r.host("**.abc.org").and().path("/image/png")
.filters(f ->
f.addResponseHeader("X-TestHeader", "foobar"))
.uri("http://httpbin.org:80")
)
.route(r -> r.path("/image/webp")
.filters(f ->
f.addResponseHeader("X-AnotherHeader", "baz"))
.uri("http://httpbin.org:80")
.metadata("key", "value")
)
.route(r -> r.order(-1)
.host("**.throttle.org").and().path("/get")
.filters(f -> f.filter(throttle.apply(1,
1,
10,
TimeUnit.SECONDS)))
.uri("http://httpbin.org:80")
.metadata("key", "value")
)
.build();
}
----
This style also allows for more custom predicate assertions.
The predicates defined by `RouteDefinitionLocator` beans are combined using logical `and`.
By using the fluent Java API, you can use the `and()`, `or()`, and `negate()` operators on the `Predicate` class.

10
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories.adoc

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
[[gatewayfilter-factories]]
= `GatewayFilter` Factories
:page-section-summary-toc: 1
Route filters allow the modification of the incoming HTTP request or outgoing HTTP response in some manner.
Route filters are scoped to a particular route.
Spring Cloud Gateway includes many built-in GatewayFilter Factories.
NOTE: For more detailed examples of how to use any of the following filters, take a look at the https://github.com/spring-cloud/spring-cloud-gateway/tree/master/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/factory[unit tests].

40
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/addrequestheader-factory.adoc

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
[[addrequestheader-gatewayfilter-factory]]
= `AddRequestHeader` `GatewayFilter` Factory
The `AddRequestHeader` `GatewayFilter` factory takes a `name` and `value` parameter.
The following example configures an `AddRequestHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: add_request_header_route
uri: https://example.org
filters:
- AddRequestHeader=X-Request-red, blue
----
This listing adds `X-Request-red:blue` header to the downstream request's headers for all matching requests.
`AddRequestHeader` is aware of the URI variables used to match a path or host.
URI variables may be used in the value and are expanded at runtime.
The following example configures an `AddRequestHeader` `GatewayFilter` that uses a variable:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: add_request_header_route
uri: https://example.org
predicates:
- Path=/red/{segment}
filters:
- AddRequestHeader=X-Request-Red, Blue-{segment}
----

44
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/addrequestheadersifnotpresent-factory.adoc

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
[[addrequestheadersifnotpresent-gatewayfilter-factory]]
= `AddRequestHeadersIfNotPresent` `GatewayFilter` Factory
The `AddRequestHeadersIfNotPresent` `GatewayFilter` factory takes a collection of `name` and `value` pairs separated by colon.
The following example configures an `AddRequestHeadersIfNotPresent` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: add_request_headers_route
uri: https://example.org
filters:
- AddRequestHeadersIfNotPresent=X-Request-Color-1:blue,X-Request-Color-2:green
----
This listing adds 2 headers `X-Request-Color-1:blue` and `X-Request-Color-2:green` to the downstream request's headers for all matching requests.
This is similar to how `AddRequestHeader` works, but unlike `AddRequestHeader` it will do it only if the header is not already there.
Otherwise, the original value in the client request is sent.
Additionally, to set a multi-valued header, use the header name multiple times like `AddRequestHeadersIfNotPresent=X-Request-Color-1:blue,X-Request-Color-1:green`.
`AddRequestHeadersIfNotPresent` also supports URI variables used to match a path or host.
URI variables may be used in the value and are expanded at runtime.
The following example configures an `AddRequestHeadersIfNotPresent` `GatewayFilter` that uses a variable:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: add_request_header_route
uri: https://example.org
predicates:
- Path=/red/{segment}
filters:
- AddRequestHeadersIfNotPresent=X-Request-Red:Blue-{segment}
----

40
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/addrequestparameter-factory.adoc

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
[[addrequestparameter-gatewayfilter-factory]]
= `AddRequestParameter` `GatewayFilter` Factory
The `AddRequestParameter` `GatewayFilter` Factory takes a `name` and `value` parameter.
The following example configures an `AddRequestParameter` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: add_request_parameter_route
uri: https://example.org
filters:
- AddRequestParameter=red, blue
----
This will add `red=blue` to the downstream request's query string for all matching requests.
`AddRequestParameter` is aware of the URI variables used to match a path or host.
URI variables may be used in the value and are expanded at runtime.
The following example configures an `AddRequestParameter` `GatewayFilter` that uses a variable:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: add_request_parameter_route
uri: https://example.org
predicates:
- Host: {segment}.myhost.org
filters:
- AddRequestParameter=foo, bar-{segment}
----

41
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/addresponseheader-factory.adoc

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
[[addresponseheader-gatewayfilter-factory]]
= `AddResponseHeader` `GatewayFilter` Factory
The `AddResponseHeader` `GatewayFilter` Factory takes a `name` and `value` parameter.
The following example configures an `AddResponseHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: add_response_header_route
uri: https://example.org
filters:
- AddResponseHeader=X-Response-Red, Blue
----
This adds `X-Response-Red:Blue` header to the downstream response's headers for all matching requests.
`AddResponseHeader` is aware of URI variables used to match a path or host.
URI variables may be used in the value and are expanded at runtime.
The following example configures an `AddResponseHeader` `GatewayFilter` that uses a variable:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: add_response_header_route
uri: https://example.org
predicates:
- Host: {segment}.myhost.org
filters:
- AddResponseHeader=foo, bar-{segment}
----

42
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/cacherequestbody-factory.adoc

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
[[cacherequestbody-gatewayfilter-factory]]
= `CacheRequestBody` `GatewayFilter` Factory
Some situations necessitate reading the request body. Since the request can be read only once, we need to cache the request body.
You can use the `CacheRequestBody` filter to cache the request body before sending it downstream and getting the body from `exchange` attribute.
The following listing shows how to cache the request body `GatewayFilter`:
[source,java]
----
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("cache_request_body_route", r -> r.path("/downstream/**")
.filters(f -> f.prefixPath("/httpbin")
.cacheRequestBody(String.class).uri(uri))
.build();
}
----
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: cache_request_body_route
uri: lb://downstream
predicates:
- Path=/downstream/**
filters:
- name: CacheRequestBody
args:
bodyClass: java.lang.String
----
`CacheRequestBody` extracts the request body and converts it to a body class (such as `java.lang.String`, defined in the preceding example).
`CacheRequestBody` then places it in the attributes available from `ServerWebExchange.getAttributes()`, with a key defined in `ServerWebExchangeUtils.CACHED_REQUEST_BODY_ATTR`.
NOTE: This filter works only with HTTP (including HTTPS) requests.

168
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/circuitbreaker-filter-factory.adoc

@ -0,0 +1,168 @@ @@ -0,0 +1,168 @@
[[spring-cloud-circuitbreaker-filter-factory]]
= `CircuitBreaker` `GatewayFilter` Factory
The Spring Cloud CircuitBreaker GatewayFilter factory uses the Spring Cloud CircuitBreaker APIs to wrap Gateway routes in
a circuit breaker. Spring Cloud CircuitBreaker supports multiple libraries that can be used with Spring Cloud Gateway. Spring Cloud supports Resilience4J out of the box.
To enable the Spring Cloud CircuitBreaker filter, you need to place `spring-cloud-starter-circuitbreaker-reactor-resilience4j` on the classpath.
The following example configures a Spring Cloud CircuitBreaker `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: circuitbreaker_route
uri: https://example.org
filters:
- CircuitBreaker=myCircuitBreaker
----
To configure the circuit breaker, see the configuration for the underlying circuit breaker implementation you are using.
* https://cloud.spring.io/spring-cloud-circuitbreaker/reference/html/spring-cloud-circuitbreaker.html[Resilience4J Documentation]
The Spring Cloud CircuitBreaker filter can also accept an optional `fallbackUri` parameter.
Currently, only `forward:` schemed URIs are supported.
If the fallback is called, the request is forwarded to the controller matched by the URI.
The following example configures such a fallback:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: circuitbreaker_route
uri: lb://backing-service:8088
predicates:
- Path=/consumingServiceEndpoint
filters:
- name: CircuitBreaker
args:
name: myCircuitBreaker
fallbackUri: forward:/inCaseOfFailureUseThis
- RewritePath=/consumingServiceEndpoint, /backingServiceEndpoint
----
The following listing does the same thing in Java:
.Application.java
[source,java]
----
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("circuitbreaker_route", r -> r.path("/consumingServiceEndpoint")
.filters(f -> f.circuitBreaker(c -> c.name("myCircuitBreaker").fallbackUri("forward:/inCaseOfFailureUseThis"))
.rewritePath("/consumingServiceEndpoint", "/backingServiceEndpoint")).uri("lb://backing-service:8088")
.build();
}
----
This example forwards to the `/inCaseofFailureUseThis` URI when the circuit breaker fallback is called.
Note that this example also demonstrates the (optional) Spring Cloud LoadBalancer load-balancing (defined by the `lb` prefix on the destination URI).
CircuitBreaker also supports URI variables in the `fallbackUri`.
This allows more complex routing options, like forwarding sections of the original host or url path using https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/pattern/PathPattern.html[PathPattern expression].
In the example below the call `consumingServiceEndpoint/users/1` will be redirected to `inCaseOfFailureUseThis/users/1`.
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: circuitbreaker_route
uri: lb://backing-service:8088
predicates:
- Path=/consumingServiceEndpoint/{*segments}
filters:
- name: CircuitBreaker
args:
name: myCircuitBreaker
fallbackUri: forward:/inCaseOfFailureUseThis/{segments}
----
The primary scenario is to use the `fallbackUri` to define an internal controller or handler within the gateway application.
However, you can also reroute the request to a controller or handler in an external application, as follows:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: ingredients
uri: lb://ingredients
predicates:
- Path=//ingredients/**
filters:
- name: CircuitBreaker
args:
name: fetchIngredients
fallbackUri: forward:/fallback
- id: ingredients-fallback
uri: http://localhost:9994
predicates:
- Path=/fallback
----
In this example, there is no `fallback` endpoint or handler in the gateway application.
However, there is one in another application, registered under `http://localhost:9994`.
In case of the request being forwarded to fallback, the Spring Cloud CircuitBreaker Gateway filter also provides the `Throwable` that has caused it.
It is added to the `ServerWebExchange` as the `ServerWebExchangeUtils.CIRCUITBREAKER_EXECUTION_EXCEPTION_ATTR` attribute that can be used when handling the fallback within the gateway application.
For the external controller/handler scenario, headers can be added with exception details.
You can find more information on doing so in the xref:spring-cloud-gateway/gatewayfilter-factories/fallback-headers.adoc[FallbackHeaders GatewayFilter Factory section].
[[circuit-breaker-status-codes]]
== Tripping The Circuit Breaker On Status Codes
In some cases you might want to trip a circuit breaker based on the status code
returned from the route it wraps. The circuit breaker config object takes a list of
status codes that if returned will cause the circuit breaker to be tripped. When setting the
status codes you want to trip the circuit breaker you can either use an integer with the status code
value or the String representation of the `HttpStatus` enumeration.
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: circuitbreaker_route
uri: lb://backing-service:8088
predicates:
- Path=/consumingServiceEndpoint
filters:
- name: CircuitBreaker
args:
name: myCircuitBreaker
fallbackUri: forward:/inCaseOfFailureUseThis
statusCodes:
- 500
- "NOT_FOUND"
----
.Application.java
[source,java]
----
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("circuitbreaker_route", r -> r.path("/consumingServiceEndpoint")
.filters(f -> f.circuitBreaker(c -> c.name("myCircuitBreaker").fallbackUri("forward:/inCaseOfFailureUseThis").addStatusCode("INTERNAL_SERVER_ERROR"))
.rewritePath("/consumingServiceEndpoint", "/backingServiceEndpoint")).uri("lb://backing-service:8088")
.build();
}
----

25
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/deduperesponseheader-factory.adoc

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
[[deduperesponseheader-gatewayfilter-factory]]
= `DedupeResponseHeader` `GatewayFilter` Factory
The `DedupeResponseHeader` GatewayFilter factory takes a `name` parameter and an optional `strategy` parameter. `name` can contain a space-separated list of header names.
The following example configures a `DedupeResponseHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: dedupe_response_header_route
uri: https://example.org
filters:
- DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
----
This removes duplicate values of `Access-Control-Allow-Credentials` and `Access-Control-Allow-Origin` response headers in cases when both the gateway CORS logic and the downstream logic add them.
The `DedupeResponseHeader` filter also accepts an optional `strategy` parameter.
The accepted values are `RETAIN_FIRST` (default), `RETAIN_LAST`, and `RETAIN_UNIQUE`.

19
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/default-filters.adoc

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
[[default-filters]]
= Default Filters
:page-section-summary-toc: 1
To add a filter and apply it to all routes, you can use `spring.cloud.gateway.default-filters`.
This property takes a list of filters.
The following listing defines a set of default filters:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
default-filters:
- AddResponseHeader=X-Response-Default-Red, Default-Blue
- PrefixPath=/httpbin
----

43
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/fallback-headers.adoc

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
[[fallback-headers]]
= `FallbackHeaders` `GatewayFilter` Factory
The `FallbackHeaders` factory lets you add Spring Cloud CircuitBreaker execution exception details in the headers of a request forwarded to a `fallbackUri` in an external application, as in the following scenario:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: ingredients
uri: lb://ingredients
predicates:
- Path=//ingredients/**
filters:
- name: CircuitBreaker
args:
name: fetchIngredients
fallbackUri: forward:/fallback
- id: ingredients-fallback
uri: http://localhost:9994
predicates:
- Path=/fallback
filters:
- name: FallbackHeaders
args:
executionExceptionTypeHeaderName: Test-Header
----
In this example, after an execution exception occurs while running the circuit breaker, the request is forwarded to the `fallback` endpoint or handler in an application running on `localhost:9994`.
The headers with the exception type, message and (if available) root cause exception type and message are added to that request by the `FallbackHeaders` filter.
You can overwrite the names of the headers in the configuration by setting the values of the following arguments (shown with their default values):
* `executionExceptionTypeHeaderName` (`"Execution-Exception-Type"`)
* `executionExceptionMessageHeaderName` (`"Execution-Exception-Message"`)
* `rootCauseExceptionTypeHeaderName` (`"Root-Cause-Exception-Type"`)
* `rootCauseExceptionMessageHeaderName` (`"Root-Cause-Exception-Message"`)
For more information on circuit breakers and the gateway see the xref:spring-cloud-gateway/gatewayfilter-factories/circuitbreaker-filter-factory.adoc[Spring Cloud CircuitBreaker Factory section].

80
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/jsontogrpc-factory.adoc

@ -0,0 +1,80 @@ @@ -0,0 +1,80 @@
[[jsontogrpc-gatewayfilter-factory]]
= `JsonToGrpc` `GatewayFilter` Factory
The JSONToGRPCFilter GatewayFilter Factory converts a JSON payload to a gRPC request.
The filter takes the following arguments:
* `protoDescriptor`: Proto descriptor file.
This file can be generated using `protoc` and specifying the `--descriptor_set_out` flag:
[source,bash]
----
protoc --proto_path=src/main/resources/proto/ \
--descriptor_set_out=src/main/resources/proto/hello.pb \
src/main/resources/proto/hello.proto
----
* `protoFile`: Proto definition file.
* `service`: Short name of the service that handles the request.
* `method`: Method name in the service that handles the request.
NOTE: `streaming` is not supported.
*application.yml.*
[source,java]
----
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("json-grpc", r -> r.path("/json/hello").filters(f -> {
String protoDescriptor = "file:src/main/proto/hello.pb";
String protoFile = "file:src/main/proto/hello.proto";
String service = "HelloService";
String method = "hello";
return f.jsonToGRPC(protoDescriptor, protoFile, service, method);
}).uri(uri))
----
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: json-grpc
uri: https://localhost:6565/testhello
predicates:
- Path=/json/**
filters:
- name: JsonToGrpc
args:
protoDescriptor: file:proto/hello.pb
protoFile: file:proto/hello.proto
service: HelloService
method: hello
----
When a request is made through the gateway to `/json/hello`, the request is transformed by using the definition provided in `hello.proto`, sent to `HelloService/hello`, and the response back is transformed to JSON.
By default, it creates a `NettyChannel` by using the default `TrustManagerFactory`. However, you can customize this `TrustManager` by creating a bean of type `GrpcSslConfigurer`:
[source,java]
----
@Configuration
public class GRPCLocalConfiguration {
@Bean
public GRPCSSLContext sslContext() {
TrustManager trustManager = trustAllCerts();
return new GRPCSSLContext(trustManager);
}
}
----

55
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/local-cache-response-filter.adoc

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
[[local-cache-response-filter]]
= `LocalResponseCache` `GatewayFilter` Factory
This filter allows caching the response body and headers to follow these rules:
* It can only cache bodiless GET requests.
* It caches the response only for one of the following status codes: HTTP 200 (OK), HTTP 206 (Partial Content), or HTTP 301 (Moved Permanently).
* Response data is not cached if `Cache-Control` header does not allow it (`no-store` present in the request or `no-store` or `private` present in the response).
* If the response is already cached and a new request is performed with no-cache value in `Cache-Control` header, it returns a bodiless response with 304 (Not Modified).
This filter configures the local response cache per route and is available only if the `spring.cloud.gateway.filter.local-response-cache.enabled` property is enabled. And a xref:spring-cloud-gateway/global-filters.adoc#local-cache-response-global-filter[local response cache configured globally] is also available as feature.
It accepts the first parameter to override the time to expire a cache entry (expressed in `s` for seconds, `m` for minutes, and `h` for hours) and a second parameter to set the maximum size of the cache to evict entries for this route (`KB`, `MB`, or `GB`).
The following listing shows how to add local response cache `GatewayFilter`:
[source,java]
----
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("rewrite_response_upper", r -> r.host("*.rewriteresponseupper.org")
.filters(f -> f.prefixPath("/httpbin")
.localResponseCache(Duration.ofMinutes(30), "500MB")
).uri(uri))
.build();
}
----
or this
.application.yaml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: resource
uri: http://localhost:9000
predicates:
- Path=/resource
filters:
- LocalResponseCache=30m,500MB
----
NOTE: This filter also automatically calculates the `max-age` value in the HTTP `Cache-Control` header.
Only if `max-age` is present on the original response is the value rewritten with the number of seconds set in the `timeToLive` configuration parameter.
In consecutive calls, this value is recalculated with the number of seconds left until the response expires.
NOTE: To enable this feature, add `com.github.ben-manes.caffeine:caffeine` and `spring-boot-starter-cache` as project dependencies.
WARNING: If your project creates custom `CacheManager` beans, it will either need to be marked with `@Primary` or injected using `@Qualifier`.

24
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/maprequestheader-factory.adoc

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
[[maprequestheader-gatewayfilter-factory]]
= `MapRequestHeader` `GatewayFilter` Factory
The `MapRequestHeader` `GatewayFilter` factory takes `fromHeader` and `toHeader` parameters.
It creates a new named header (`toHeader`), and the value is extracted out of an existing named header (`fromHeader`) from the incoming http request.
If the input header does not exist, the filter has no impact.
If the new named header already exists, its values are augmented with the new values.
The following example configures a `MapRequestHeader`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: map_request_header_route
uri: https://example.org
filters:
- MapRequestHeader=Blue, X-Request-Red
----
This adds the `X-Request-Red:<values>` header to the downstream request with updated values from the incoming HTTP request's `Blue` header.

44
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/modifyrequestbody-factory.adoc

@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
[[modifyrequestbody-gatewayfilter-factory]]
= `ModifyRequestBody` `GatewayFilter` Factory
You can use the `ModifyRequestBody` filter to modify the request body before it is sent downstream by the gateway.
NOTE: This filter can be configured only by using the Java DSL.
The following listing shows how to modify a request body `GatewayFilter`:
[source,java]
----
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("rewrite_request_obj", r -> r.host("*.rewriterequestobj.org")
.filters(f -> f.prefixPath("/httpbin")
.modifyRequestBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE,
(exchange, s) -> Mono.just(new Hello(s.toUpperCase())))).uri(uri))
.build();
}
static class Hello {
String message;
public Hello() { }
public Hello(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
----
NOTE: If the request has no body, the `RewriteFilter` is passed `null`. `Mono.empty()` should be returned to assign a missing body in the request.

24
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/modifyresponsebody-factory.adoc

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
[[modifyresponsebody-gatewayfilter-factory]]
= `ModifyResponseBody` `GatewayFilter` Factory
You can use the `ModifyResponseBody` filter to modify the response body before it is sent back to the client.
NOTE: This filter can be configured only by using the Java DSL.
The following listing shows how to modify a response body `GatewayFilter`:
[source,java]
----
@Bean
public RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("rewrite_response_upper", r -> r.host("*.rewriteresponseupper.org")
.filters(f -> f.prefixPath("/httpbin")
.modifyResponseBody(String.class, String.class,
(exchange, s) -> Mono.just(s.toUpperCase()))).uri(uri))
.build();
}
----
NOTE: If the response has no body, the `RewriteFilter` is passed `null`. `Mono.empty()` should be returned to assign a missing body in the response.

23
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/prefixpath-factory.adoc

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
[[prefixpath-gatewayfilter-factory]]
= `PrefixPath` `GatewayFilter` Factory
:page-section-summary-toc: 1
The `PrefixPath` `GatewayFilter` factory takes a single `prefix` parameter.
The following example configures a `PrefixPath` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: prefixpath_route
uri: https://example.org
filters:
- PrefixPath=/mypath
----
This prefixes `/mypath` to the path of all matching requests.
So a request to `/hello` is sent to `/mypath/hello`.

21
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/preservehostheader-factory.adoc

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
[[preservehostheader-gatewayfilter-factory]]
= `PreserveHostHeader` `GatewayFilter` Factory
:page-section-summary-toc: 1
The `PreserveHostHeader` `GatewayFilter` factory has no parameters.
This filter sets a request attribute that the routing filter inspects to determine if the original host header should be sent rather than the host header determined by the HTTP client.
The following example configures a `PreserveHostHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: preserve_host_route
uri: https://example.org
filters:
- PreserveHostHeader
----

26
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/redirectto-factory.adoc

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
[[redirectto-gatewayfilter-factory]]
= `RedirectTo` `GatewayFilter` Factory
The `RedirectTo` `GatewayFilter` factory takes two parameters, `status` and `url`.
The `status` parameter should be a 300 series redirect HTTP code, such as 301.
The `url` parameter should be a valid URL.
This is the value of the `Location` header.
For relative redirects, you should use `uri: no://op` as the uri of your route definition.
The following listing configures a `RedirectTo` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: prefixpath_route
uri: https://example.org
filters:
- RedirectTo=302, https://acme.org
----
This will send a status 302 with a `Location:https://acme.org` header to perform a redirect.

42
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/removejsonattributesresponsebody-factory.adoc

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
[[removejsonattributesresponsebody-gatewayfilter-factory]]
= `RemoveJsonAttributesResponseBody` `GatewayFilter` Factory
The `RemoveJsonAttributesResponseBody` `GatewayFilter` factory takes a collection of `attribute names` to search for, an optional last parameter from the list can be a boolean to remove the attributes just at root level (that's the default value if not present at the end of the parameter configuration, `false`) or recursively (`true`).
It provides a convenient method to apply a transformation to JSON body content by deleting attributes from it.
The following example configures an `RemoveJsonAttributesResponseBody` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: removejsonattributes_route
uri: https://example.org
filters:
- RemoveJsonAttributesResponseBody=id,color
----
This removes attributes "id" and "color" from the JSON content body at root level.
The following example configures an `RemoveJsonAttributesResponseBody` `GatewayFilter` that uses the optional last parameter:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: removejsonattributes_recursively_route
uri: https://example.org
predicates:
- Path=/red/{segment}
filters:
- RemoveJsonAttributesResponseBody=id,color,true
----
This removes attributes "id" and "color" from the JSON content body at any level.

23
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/removerequestheader-factory.adoc

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
[[removerequestheader-gatewayfilter-factory]]
= `RemoveRequestHeader` GatewayFilter Factory
:page-section-summary-toc: 1
The `RemoveRequestHeader` `GatewayFilter` factory takes a `name` parameter.
It is the name of the header to be removed.
The following listing configures a `RemoveRequestHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: removerequestheader_route
uri: https://example.org
filters:
- RemoveRequestHeader=X-Request-Foo
----
This removes the `X-Request-Foo` header before it is sent downstream.

24
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/removerequestparameter-factory.adoc

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
[[removerequestparameter-gatewayfilter-factory]]
= `RemoveRequestParameter` `GatewayFilter` Factory
:page-section-summary-toc: 1
The `RemoveRequestParameter` `GatewayFilter` factory takes a `name` parameter.
It is the name of the query parameter to be removed.
The following example configures a `RemoveRequestParameter` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: removerequestparameter_route
uri: https://example.org
filters:
- RemoveRequestParameter=red
----
This will remove the `red` parameter before it is sent downstream.

26
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/removeresponseheader-factory.adoc

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
[[removeresponseheader-gatewayfilter-factory]]
= `RemoveResponseHeader` `GatewayFilter` Factory
The `RemoveResponseHeader` `GatewayFilter` factory takes a `name` parameter.
It is the name of the header to be removed.
The following listing configures a `RemoveResponseHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: removeresponseheader_route
uri: https://example.org
filters:
- RemoveResponseHeader=X-Response-Foo
----
This will remove the `X-Response-Foo` header from the response before it is returned to the gateway client.
To remove any kind of sensitive header, you should configure this filter for any routes for which you may want to do so.
In addition, you can configure this filter once by using `spring.cloud.gateway.default-filters` and have it applied to all routes.

23
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/requestheadersize-factory.adoc

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
[[requestheadersize-gatewayfilter-factory]]
= `RequestHeaderSize` `GatewayFilter` Factory
:page-section-summary-toc: 1
The `RequestHeaderSize` `GatewayFilter` factory takes `maxSize` and `errorHeaderName` parameters.
The `maxSize` parameter is the maximum data size allowed by the request header (including key and value). The `errorHeaderName` parameter sets the name of the response header containing an error message, by default it is "errorMessage".
The following listing configures a `RequestHeaderSize` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: requestheadersize_route
uri: https://example.org
filters:
- RequestHeaderSize=1000B
----
This will send a status 431 if size of any request header is greater than 1000 Bytes.

120
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/requestratelimiter-factory.adoc

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
[[requestratelimiter-gatewayfilter-factory]]
= `RequestRateLimiter` `GatewayFilter` Factory
The `RequestRateLimiter` `GatewayFilter` factory uses a `RateLimiter` implementation to determine if the current request is allowed to proceed. If it is not, a status of `HTTP 429 - Too Many Requests` (by default) is returned.
This filter takes an optional `keyResolver` parameter and parameters specific to the rate limiter (described xref:spring-cloud-gateway/gatewayfilter-factories/requestratelimiter-factory.adoc#key-resolver-section[later in this section]).
`keyResolver` is a bean that implements the `KeyResolver` interface.
In configuration, reference the bean by name using SpEL.
`#{@myKeyResolver}` is a SpEL expression that references a bean named `myKeyResolver`.
The following listing shows the `KeyResolver` interface:
.KeyResolver.java
[source,java]
----
public interface KeyResolver {
Mono<String> resolve(ServerWebExchange exchange);
}
----
[[key-resolver-section]]
The `KeyResolver` interface lets pluggable strategies derive the key for limiting requests.
In future milestone releases, there will be some `KeyResolver` implementations.
The default implementation of `KeyResolver` is the `PrincipalNameKeyResolver`, which retrieves the `Principal` from the `ServerWebExchange` and calls `Principal.getName()`.
By default, if the `KeyResolver` does not find a key, requests are denied.
You can adjust this behavior by setting the `spring.cloud.gateway.filter.request-rate-limiter.deny-empty-key` (`true` or `false`) and `spring.cloud.gateway.filter.request-rate-limiter.empty-key-status-code` properties.
[NOTE]
=====
The `RequestRateLimiter` is not configurable with the "shortcut" notation. The following example below is _invalid_:
.application.properties
----
# INVALID SHORTCUT CONFIGURATION
spring.cloud.gateway.routes[0].filters[0]=RequestRateLimiter=2, 2, #{@userkeyresolver}
----
=====
[[redis-ratelimiter]]
== The Redis `RateLimiter`
The Redis implementation is based on work done at https://stripe.com/blog/rate-limiters[Stripe].
It requires the use of the `spring-boot-starter-data-redis-reactive` Spring Boot starter.
The algorithm used is the https://en.wikipedia.org/wiki/Token_bucket[Token Bucket Algorithm].
The `redis-rate-limiter.replenishRate` property defines how many requests per second to allow (without any dropped requests).
This is the rate at which the token bucket is filled.
The `redis-rate-limiter.burstCapacity` property is the maximum number of requests a user is allowed in a single second (without any dropped requests).
This is the number of tokens the token bucket can hold.
Setting this value to zero blocks all requests.
The `redis-rate-limiter.requestedTokens` property is how many tokens a request costs.
This is the number of tokens taken from the bucket for each request and defaults to `1`.
A steady rate is accomplished by setting the same value in `replenishRate` and `burstCapacity`.
Temporary bursts can be allowed by setting `burstCapacity` higher than `replenishRate`.
In this case, the rate limiter needs to be allowed some time between bursts (according to `replenishRate`), as two consecutive bursts results in dropped requests (`HTTP 429 - Too Many Requests`).
The following listing configures a `redis-rate-limiter`:
Rate limits below `1 request/s` are accomplished by setting `replenishRate` to the wanted number of requests, `requestedTokens` to the timespan in seconds, and `burstCapacity` to the product of `replenishRate` and `requestedTokens`.
For example, setting `replenishRate=1`, `requestedTokens=60`, and `burstCapacity=60` results in a limit of `1 request/min`.
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: requestratelimiter_route
uri: https://example.org
filters:
- name: RequestRateLimiter
args:
redis-rate-limiter.replenishRate: 10
redis-rate-limiter.burstCapacity: 20
redis-rate-limiter.requestedTokens: 1
----
The following example configures a `KeyResolver` in Java:
.Config.java
[source,java]
----
@Bean
KeyResolver userKeyResolver() {
return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("user"));
}
----
This defines a request rate limit of 10 per user. A burst of 20 is allowed, but, in the next second, only 10 requests are available.
The `KeyResolver` is a simple one that gets the `user` request parameter
NOTE: This is not recommended for production
You can also define a rate limiter as a bean that implements the `RateLimiter` interface.
In configuration, you can reference the bean by name using SpEL.
`#{@myRateLimiter}` is a SpEL expression that references a bean with named `myRateLimiter`.
The following listing defines a rate limiter that uses the `KeyResolver` defined in the previous listing:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: requestratelimiter_route
uri: https://example.org
filters:
- name: RequestRateLimiter
args:
rate-limiter: "#{@myRateLimiter}"
key-resolver: "#{@userKeyResolver}"
----

35
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/requestsize-factory.adoc

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
[[requestsize-gatewayfilter-factory]]
= `RequestSize` `GatewayFilter` Factory
When the request size is greater than the permissible limit, the `RequestSize` `GatewayFilter` factory can restrict a request from reaching the downstream service.
The filter takes a `maxSize` parameter.
The `maxSize` is a `DataSize` type, so values can be defined as a number followed by an optional `DataUnit` suffix such as 'KB' or 'MB'. The default is 'B' for bytes.
It is the permissible size limit of the request defined in bytes.
The following listing configures a `RequestSize` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: request_size_route
uri: http://localhost:8080/upload
predicates:
- Path=/upload
filters:
- name: RequestSize
args:
maxSize: 5000000
----
The `RequestSize` `GatewayFilter` factory sets the response status as `413 Payload Too Large` with an additional header `errorMessage` when the request is rejected due to size. The following example shows such an `errorMessage`:
[source]
----
errorMessage : Request size is larger than permissible limit. Request size is 6.0 MB where permissible limit is 5.0 MB
----
NOTE: The default request size is set to five MB if not provided as a filter argument in the route definition.

86
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/retry-factory.adoc

@ -0,0 +1,86 @@ @@ -0,0 +1,86 @@
[[retry-gatewayfilter-factory]]
= `Retry` `GatewayFilter` Factory
The `Retry` `GatewayFilter` factory supports the following parameters:
* `retries`: The number of retries that should be attempted.
* `statuses`: The HTTP status codes that should be retried, represented by using `org.springframework.http.HttpStatus`.
* `methods`: The HTTP methods that should be retried, represented by using `org.springframework.http.HttpMethod`.
* `series`: The series of status codes to be retried, represented by using `org.springframework.http.HttpStatus.Series`.
* `exceptions`: A list of thrown exceptions that should be retried.
* `backoff`: The configured exponential backoff for the retries.
Retries are performed after a backoff interval of `firstBackoff * (factor ^ n)`, where `n` is the iteration.
If `maxBackoff` is configured, the maximum backoff applied is limited to `maxBackoff`.
If `basedOnPreviousValue` is true, the backoff is calculated by using `prevBackoff * factor`.
The following defaults are configured for `Retry` filter, if enabled:
* `retries`: Three times
* `series`: 5XX series
* `methods`: GET method
* `exceptions`: `IOException` and `TimeoutException`
* `backoff`: disabled
The following listing configures a Retry `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: retry_test
uri: http://localhost:8080/flakey
predicates:
- Host=*.retry.com
filters:
- name: Retry
args:
retries: 3
statuses: BAD_GATEWAY
methods: GET,POST
backoff:
firstBackoff: 10ms
maxBackoff: 50ms
factor: 2
basedOnPreviousValue: false
----
NOTE: When using the retry filter with a `forward:` prefixed URL, the target endpoint should be written carefully so that, in case of an error, it does not do anything that could result in a response being sent to the client and committed.
For example, if the target endpoint is an annotated controller, the target controller method should not return `ResponseEntity` with an error status code.
Instead, it should throw an `Exception` or signal an error (for example, through a `Mono.error(ex)` return value), which the retry filter can be configured to handle by retrying.
WARNING: When using the retry filter with any HTTP method with a body, the body will be cached and the gateway will become memory constrained. The body is cached in a request attribute defined by `ServerWebExchangeUtils.CACHED_REQUEST_BODY_ATTR`. The type of the object is `org.springframework.core.io.buffer.DataBuffer`.
A simplified "shortcut" notation can be added with a single `status` and `method`.
The following two examples are equivalent:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: retry_route
uri: https://example.org
filters:
- name: Retry
args:
retries: 3
statuses: INTERNAL_SERVER_ERROR
methods: GET
backoff:
firstBackoff: 10ms
maxBackoff: 50ms
factor: 2
basedOnPreviousValue: false
- id: retryshortcut_route
uri: https://example.org
filters:
- Retry=3,INTERNAL_SERVER_ERROR,GET,10ms,50ms,2,false
----

35
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/rewritelocationresponseheader-factory.adoc

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
[[rewritelocationresponseheader-gatewayfilter-factory]]
= `RewriteLocationResponseHeader` `GatewayFilter` Factory
The `RewriteLocationResponseHeader` `GatewayFilter` factory modifies the value of the `Location` response header, usually to get rid of backend-specific details.
It takes the `stripVersionMode`, `locationHeaderName`, `hostValue`, and `protocolsRegex` parameters.
The following listing configures a `RewriteLocationResponseHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: rewritelocationresponseheader_route
uri: http://example.org
filters:
- RewriteLocationResponseHeader=AS_IN_REQUEST, Location, ,
----
For example, for a request of `POST https://api.example.com/some/object/name`, the `Location` response header value of `https://object-service.prod.example.net/v2/some/object/id` is rewritten as `https://api.example.com/some/object/id`.
The `stripVersionMode` parameter has the following possible values: `NEVER_STRIP`, `AS_IN_REQUEST` (default), and `ALWAYS_STRIP`.
* `NEVER_STRIP`: The version is not stripped, even if the original request path contains no version.
* `AS_IN_REQUEST`: The version is stripped only if the original request path contains no version.
* `ALWAYS_STRIP`: The version is always stripped, even if the original request path contains version.
The `hostValue` parameter, if provided, is used to replace the `host:port` portion of the response `Location` header.
If it is not provided, the value of the `Host` request header is used.
The `protocolsRegex` parameter must be a valid regex `String`, against which the protocol name is matched.
If it is not matched, the filter does nothing.
The default is `http|https|ftp|ftps`.

24
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/rewritepath-factory.adoc

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
[[rewritepath-gatewayfilter-factory]]
= `RewritePath` `GatewayFilter` Factory
The `RewritePath` `GatewayFilter` factory takes a path `regexp` parameter and a `replacement` parameter.
This uses Java regular expressions for a flexible way to rewrite the request path.
The following listing configures a `RewritePath` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: rewritepath_route
uri: https://example.org
predicates:
- Path=/red/**
filters:
- RewritePath=/red/?(?<segment>.*), /$\{segment}
----
For a request path of `/red/blue`, this sets the path to `/blue` before making the downstream request. Note that the `$` should be replaced with `$\` because of the YAML specification.

26
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/rewriterequestparameter-factory.adoc

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
= `RewriteRequestParameter` `GatewayFilter` Factory
The `RewriteRequestParameter` `GatewayFilter` factory takes a `name` parameter and a `replacement` parameter.
It will rewrite the value of the request parameter of the given `name`.
If multiple request parameters with the same `name` are set, they will be replaced with a single value.
If no request parameter is found, no changes will be made.
The following listing configures a `RewriteRequestParameter` `GatewayFilter`:
.application.yml
====
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: rewriterequestparameter_route
uri: https://example.org
predicates:
- Path=/products
filters:
- RewriteRequestParameter=campaign,fall2023
----
====
For a request to `/products?campaign=old`, this sets the request parameter to `campaign=fall2023`.

24
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/rewriteresponseheader-factory.adoc

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
[[rewriteresponseheader-gatewayfilter-factory]]
= `RewriteResponseHeader` `GatewayFilter` Factory
:page-section-summary-toc: 1
The `RewriteResponseHeader` `GatewayFilter` factory takes `name`, `regexp`, and `replacement` parameters.
It uses Java regular expressions for a flexible way to rewrite the response header value.
The following example configures a `RewriteResponseHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: rewriteresponseheader_route
uri: https://example.org
filters:
- RewriteResponseHeader=X-Response-Red, , password=[^&]+, password=***
----
For a header value of `/42?user=ford&password=omg!what&flag=true`, it is set to `/42?user=ford&password=\***&flag=true` after making the downstream request.
You must use `$\` to mean `$` because of the YAML specification.

24
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/savesession-factory.adoc

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
[[savesession-gatewayfilter-factory]]
= `SaveSession` `GatewayFilter` Factory
The `SaveSession` `GatewayFilter` factory forces a `WebSession::save` operation _before_ forwarding the call downstream.
This is of particular use when using something like https://projects.spring.io/spring-session/[Spring Session] with a lazy data store, and you need to ensure the session state has been saved before making the forwarded call.
The following example configures a `SaveSession` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: save_session
uri: https://example.org
predicates:
- Path=/foo/**
filters:
- SaveSession
----
If you integrate https://projects.spring.io/spring-security/[Spring Security] with Spring Session and want to ensure security details have been forwarded to the remote process, this is critical.

38
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/secureheaders-factory.adoc

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
[[secureheaders-gatewayfilter-factory]]
= `SecureHeaders` `GatewayFilter` Factory
The `SecureHeaders` `GatewayFilter` factory adds a number of headers to the response, per the recommendation made in https://blog.appcanary.com/2017/http-security-headers.html[this blog post].
The following headers (shown with their default values) are added:
* `X-Xss-Protection:1 (mode=block`)
* `Strict-Transport-Security (max-age=631138519`)
* `X-Frame-Options (DENY)`
* `X-Content-Type-Options (nosniff)`
* `Referrer-Policy (no-referrer)`
* `Content-Security-Policy (default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline)'`
* `X-Download-Options (noopen)`
* `X-Permitted-Cross-Domain-Policies (none)`
To change the default values, set the appropriate property in the `spring.cloud.gateway.filter.secure-headers` namespace.
The following properties are available:
* `xss-protection-header`
* `strict-transport-security`
* `frame-options`
* `content-type-options`
* `referrer-policy`
* `content-security-policy`
* `download-options`
* `permitted-cross-domain-policies`
To disable the default values set the `spring.cloud.gateway.filter.secure-headers.disable` property with comma-separated values.
The following example shows how to do so:
[source]
----
spring.cloud.gateway.filter.secure-headers.disable=x-frame-options,strict-transport-security
----
NOTE: The lowercase full name of the secure header needs to be used to disable it..

26
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setpath-factory.adoc

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
[[setpath-gatewayfilter-factory]]
= `SetPath` `GatewayFilter` Factory
The `SetPath` `GatewayFilter` factory takes a path `template` parameter.
It offers a simple way to manipulate the request path by allowing templated segments of the path.
This uses the URI templates from Spring Framework.
Multiple matching segments are allowed.
The following example configures a `SetPath` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: setpath_route
uri: https://example.org
predicates:
- Path=/red/{segment}
filters:
- SetPath=/{segment}
----
For a request path of `/red/blue`, this sets the path to `/blue` before making the downstream request.

41
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setrequestheader-factory.adoc

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
[[setrequestheader-gatewayfilter-factory]]
= `SetRequestHeader` `GatewayFilter` Factory
The `SetRequestHeader` `GatewayFilter` factory takes `name` and `value` parameters.
The following listing configures a `SetRequestHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: setrequestheader_route
uri: https://example.org
filters:
- SetRequestHeader=X-Request-Red, Blue
----
This `GatewayFilter` replaces (rather than adding) all headers with the given name.
So, if the downstream server responded with `X-Request-Red:1234`, it will be replaced with `X-Request-Red:Blue`, which is what the downstream service would receive.
`SetRequestHeader` is aware of URI variables used to match a path or host.
URI variables may be used in the value and are expanded at runtime.
The following example configures an `SetRequestHeader` `GatewayFilter` that uses a variable:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: setrequestheader_route
uri: https://example.org
predicates:
- Host: {segment}.myhost.org
filters:
- SetRequestHeader=foo, bar-{segment}
----

27
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setrequesthostheader-factory.adoc

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
[[setrequesthostheader-gatewayfilter-factory]]
= `SetRequestHostHeader` `GatewayFilter` Factory
There are certain situation when the host header may need to be overridden. In this situation, the `SetRequestHostHeader` `GatewayFilter` factory can replace the existing host header with a specified value.
The filter takes a `host` parameter.
The following listing configures a `SetRequestHostHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: set_request_host_header_route
uri: http://localhost:8080/headers
predicates:
- Path=/headers
filters:
- name: SetRequestHostHeader
args:
host: example.org
----
The `SetRequestHostHeader` `GatewayFilter` factory replaces the value of the host header with `example.org`.

41
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setresponseheader-factory.adoc

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
[[setresponseheader-gatewayfilter-factory]]
= `SetResponseHeader` `GatewayFilter` Factory
The `SetResponseHeader` `GatewayFilter` factory takes `name` and `value` parameters.
The following listing configures a `SetResponseHeader` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: setresponseheader_route
uri: https://example.org
filters:
- SetResponseHeader=X-Response-Red, Blue
----
This GatewayFilter replaces (rather than adding) all headers with the given name.
So, if the downstream server responded with `X-Response-Red:1234`, it will be replaced with `X-Response-Red:Blue`, which is what the gateway client would receive.
`SetResponseHeader` is aware of URI variables used to match a path or host.
URI variables may be used in the value and will be expanded at runtime.
The following example configures an `SetResponseHeader` `GatewayFilter` that uses a variable:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: setresponseheader_route
uri: https://example.org
predicates:
- Host: {segment}.myhost.org
filters:
- SetResponseHeader=foo, bar-{segment}
----

40
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/setstatus-factory.adoc

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
[[setstatus-gatewayfilter-factory]]
= `SetStatus` `GatewayFilter` Factory
The `SetStatus` `GatewayFilter` factory takes a single parameter, `status`.
It must be a valid Spring `HttpStatus`.
It may be the integer value `404` or the string representation of the enumeration: `NOT_FOUND`.
The following listing configures a `SetStatus` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: setstatusstring_route
uri: https://example.org
filters:
- SetStatus=UNAUTHORIZED
- id: setstatusint_route
uri: https://example.org
filters:
- SetStatus=401
----
In either case, the HTTP status of the response is set to 401.
You can configure the `SetStatus` `GatewayFilter` to return the original HTTP status code from the proxied request in a header in the response.
The header is added to the response if configured with the following property:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
set-status:
original-status-header-name: original-http-status
----

24
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/stripprefix-factory.adoc

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
[[stripprefix-gatewayfilter-factory]]
= `StripPrefix` `GatewayFilter` Factory
The `StripPrefix` `GatewayFilter` factory takes one parameter, `parts`.
The `parts` parameter indicates the number of parts in the path to strip from the request before sending it downstream.
The following listing configures a `StripPrefix` `GatewayFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: nameRoot
uri: https://nameservice
predicates:
- Path=/name/**
filters:
- StripPrefix=2
----
When a request is made through the gateway to `/name/blue/red`, the request made to `nameservice` looks like `https://nameservice/red`.

103
docs/modules/ROOT/pages/spring-cloud-gateway/gatewayfilter-factories/tokenrelay-factory.adoc

@ -0,0 +1,103 @@ @@ -0,0 +1,103 @@
[[tokenrelay-gatewayfilter-factory]]
= `TokenRelay` `GatewayFilter` Factory
A Token Relay is where an OAuth2 consumer acts as a Client and
forwards the incoming token to outgoing resource requests. The
consumer can be a pure Client (like an SSO application) or a Resource
Server.
Spring Cloud Gateway can forward OAuth2 access tokens downstream to the services
it is proxying using the `TokenRelay` `GatewayFilter`.
The `TokenRelay` `GatewayFilter` takes one optional parameter, `clientRegistrationId`.
The following example configures a `TokenRelay` `GatewayFilter`:
.App.java
[source,java]
----
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("resource", r -> r.path("/resource")
.filters(f -> f.tokenRelay("myregistrationid"))
.uri("http://localhost:9000"))
.build();
}
----
or this
.application.yaml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: resource
uri: http://localhost:9000
predicates:
- Path=/resource
filters:
- TokenRelay=myregistrationid
----
The example above specifies a `clientRegistrationId`, which can be used to obtain and forward an OAuth2 access token for any available `ClientRegistration`.
Spring Cloud Gateway can also forward the OAuth2 access token of the currently authenticated user `oauth2Login()` is used to authenticate the user.
To add this functionality to the gateway, you can omit the `clientRegistrationId` parameter like this:
.App.java
[source,java]
----
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("resource", r -> r.path("/resource")
.filters(f -> f.tokenRelay())
.uri("http://localhost:9000"))
.build();
}
----
or this
.application.yaml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: resource
uri: http://localhost:9000
predicates:
- Path=/resource
filters:
- TokenRelay=
----
and it will (in addition to logging the user in and grabbing a token)
pass the authentication token downstream to the services (in this case
`/resource`).
To enable this for Spring Cloud Gateway add the following dependencies
- `org.springframework.boot:spring-boot-starter-oauth2-client`
How does it work? The {github-code}/src/main/java/org/springframework/cloud/gateway/security/TokenRelayGatewayFilterFactory.java[filter]
extracts an OAuth2 access token from the currently authenticated user for the provided `clientRegistrationId`.
If no `clientRegistrationId` is provided, the currently authenticated user's own access token (obtained during login) is used.
In either case, the extracted access token is placed in a request header for the downstream requests.
For a full working sample see https://github.com/spring-cloud-samples/sample-gateway-oauth2login[this project].
NOTE: A `TokenRelayGatewayFilterFactory` bean will only be created if the proper `spring.security.oauth2.client.*` properties are set which will trigger creation of a `ReactiveClientRegistrationRepository` bean.
NOTE: The default implementation of `ReactiveOAuth2AuthorizedClientService` used by `TokenRelayGatewayFilterFactory`
uses an in-memory data store. You will need to provide your own implementation `ReactiveOAuth2AuthorizedClientService`
if you need a more robust solution.

200
docs/modules/ROOT/pages/spring-cloud-gateway/global-filters.adoc

@ -0,0 +1,200 @@ @@ -0,0 +1,200 @@
[[global-filters]]
= Global Filters
The `GlobalFilter` interface has the same signature as `GatewayFilter`.
These are special filters that are conditionally applied to all routes.
NOTE: This interface and its usage are subject to change in future milestone releases.
[[gateway-combined-global-filter-and-gatewayfilter-ordering]]
== Combined Global Filter and `GatewayFilter` Ordering
When a request matches a route, the filtering web handler adds all instances of `GlobalFilter` and all route-specific instances of `GatewayFilter` to a filter chain.
This combined filter chain is sorted by the `org.springframework.core.Ordered` interface, which you can set by implementing the `getOrder()` method.
As Spring Cloud Gateway distinguishes between "`pre`" and "`post`" phases for filter logic execution (see xref:spring-cloud-gateway/how-it-works.adoc[How it Works]), the filter with the highest precedence is the first in the "`pre`"-phase and the last in the "`post`"-phase.
The following listing configures a filter chain:
.ExampleConfiguration.java
[source,java]
----
@Bean
public GlobalFilter customFilter() {
return new CustomGlobalFilter();
}
public class CustomGlobalFilter implements GlobalFilter, Ordered {
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
log.info("custom global filter");
return chain.filter(exchange);
}
@Override
public int getOrder() {
return -1;
}
}
----
[[gateway-metrics-filter]]
== The Gateway Metrics Filter
To enable gateway metrics, add `spring-boot-starter-actuator` as a project dependency. Then, by default, the gateway metrics filter runs as long as the `spring.cloud.gateway.metrics.enabled` property is not set to `false`.
This filter adds a timer metric named `spring.cloud.gateway.requests` with the following tags:
* `routeId`: The route ID.
* `routeUri`: The URI to which the API is routed.
* `outcome`: The outcome, as classified by link:https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/HttpStatus.Series.html[HttpStatus.Series].
* `status`: The HTTP status of the request returned to the client.
* `httpStatusCode`: The HTTP Status of the request returned to the client.
* `httpMethod`: The HTTP method used for the request.
In addition, through the `spring.cloud.gateway.metrics.tags.path.enabled` property (by default, `false`), you can activate an extra metric with the path tag:
* `path`: The path of the request.
These metrics are then available to be scraped from `/actuator/metrics/spring.cloud.gateway.requests` and can be easily integrated with Prometheus to create a link:images/gateway-grafana-dashboard.jpeg[Grafana] link:gateway-grafana-dashboard.json[dashboard].
NOTE: To enable the prometheus endpoint, add `micrometer-registry-prometheus` as a project dependency.
[[local-cache-response-global-filter]]
== The Local Response Cache Filter
The `LocalResponseCache` runs if associated properties are enabled:
* `spring.cloud.gateway.global-filter.local-response-cache.enabled`: Activates the global cache for all routes
* `spring.cloud.gateway.filter.local-response-cache.enabled`: Activates the associated filter to use at route level
This feature enables a local cache using Caffeine for all responses that meet the following criteria:
* The request is a bodiless GET.
* The response has one of the following status codes: HTTP 200 (OK), HTTP 206 (Partial Content), or HTTP 301 (Moved Permanently).
* The HTTP `Cache-Control` header allows caching (that means it does not have any of the following values: `no-store` present in the request and `no-store` or `private` present in the response).
It accepts two configuration parameters:
* `spring.cloud.gateway.filter.local-response-cache.size`: Sets the maximum size of the cache to evict entries for this route (in KB, MB and GB).
* `spring.cloud.gateway.filter.local-response-cache.time-to-live` Sets the time to expire a cache entry (expressed in s for seconds, m for minutes, and h for hours).
If none of these parameters are configured but the global filter is enabled, by default, it configures 5 minutes of time to live for the cached response.
This filter also implements the automatic calculation of the `max-age` value in the HTTP `Cache-Control` header.
If `max-age` is present on the original response, the value is rewritten with the number of seconds set in the `timeToLive` configuration parameter.
In subsequent calls, this value is recalculated with the number of seconds left until the response expires.
Setting `spring.cloud.gateway.global-filter.local-response-cache.enabled` to `false` deactivate the local response cache for all routes, the xref:spring-cloud-gateway/gatewayfilter-factories/local-cache-response-filter.adoc[LocalResponseCache filter] allows to use this functionality at route level.
NOTE: To enable this feature, add `com.github.ben-manes.caffeine:caffeine` and `spring-boot-starter-cache` as project dependencies.
WARNING: If your project creates custom `CacheManager` beans, it will either need to be marked with `@Primary` or injected using `@Qualifier`.
[[forward-routing-filter]]
== Forward Routing Filter
The `ForwardRoutingFilter` looks for a URI in the exchange attribute `ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR`.
If the URL has a `forward` scheme (such as `forward:///localendpoint`), it uses the Spring `DispatcherHandler` to handle the request.
The path part of the request URL is overridden with the path in the forward URL.
The unmodified original URL is appended to the list in the `ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR` attribute.
[[netty-routing-filter]]
== The Netty Routing Filter
The Netty routing filter runs if the URL located in the `ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR` exchange attribute has a `http` or `https` scheme.
It uses the Netty `HttpClient` to make the downstream proxy request.
The response is put in the `ServerWebExchangeUtils.CLIENT_RESPONSE_ATTR` exchange attribute for use in a later filter.
(There is also an experimental `WebClientHttpRoutingFilter` that performs the same function but does not require Netty.)
[[netty-write-response-filter]]
== The Netty Write Response Filter
The `NettyWriteResponseFilter` runs if there is a Netty `HttpClientResponse` in the `ServerWebExchangeUtils.CLIENT_RESPONSE_ATTR` exchange attribute.
It runs after all other filters have completed and writes the proxy response back to the gateway client response.
(There is also an experimental `WebClientWriteResponseFilter` that performs the same function but does not require Netty.)
[[reactive-loadbalancer-client-filter]]
== `ReactiveLoadBalancerClientFilter`
The `ReactiveLoadBalancerClientFilter` looks for a URI in the exchange attribute named `ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR`.
If the URL has a `lb` scheme (such as `lb://myservice`), it uses the Spring Cloud `ReactorLoadBalancer` to resolve the name (`myservice` in this example) to an actual host and port and replaces the URI in the same attribute.
The unmodified original URL is appended to the list in the `ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR` attribute.
The filter also looks in the `ServerWebExchangeUtils.GATEWAY_SCHEME_PREFIX_ATTR` attribute to see if it equals `lb`.
If so, the same rules apply.
The following listing configures a `ReactiveLoadBalancerClientFilter`:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: myRoute
uri: lb://service
predicates:
- Path=/service/**
----
NOTE: By default, when a service instance cannot be found by the `ReactorLoadBalancer`, a `503` is returned.
You can configure the gateway to return a `404` by setting `spring.cloud.gateway.loadbalancer.use404=true`.
NOTE: The `isSecure` value of the `ServiceInstance` returned from the `ReactiveLoadBalancerClientFilter` overrides
the scheme specified in the request made to the Gateway.
For example, if the request comes into the Gateway over `HTTPS` but the `ServiceInstance` indicates it is not secure, the downstream request is made over `HTTP`.
The opposite situation can also apply.
However, if `GATEWAY_SCHEME_PREFIX_ATTR` is specified for the route in the Gateway configuration, the prefix is stripped and the resulting scheme from the route URL overrides the `ServiceInstance` configuration.
TIP: Gateway supports all the LoadBalancer features. You can read more about them in the https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#spring-cloud-loadbalancer[Spring Cloud Commons documentation].
[[routetorequesturl-filter]]
== `RouteToRequestUrl` Filter
If there is a `Route` object in the `ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR` exchange attribute, the `RouteToRequestUrlFilter` runs.
It creates a new URI, based off of the request URI but updated with the URI attribute of the `Route` object.
The new URI is placed in the `ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR` exchange attribute.
If the URI has a scheme prefix, such as `lb:ws://serviceid`, the `lb` scheme is stripped from the URI and placed in the `ServerWebExchangeUtils.GATEWAY_SCHEME_PREFIX_ATTR` for use later in the filter chain.
[[websocket-routing-filter]]
== The Websocket Routing Filter
If the URL located in the `ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR` exchange attribute has a `ws` or `wss` scheme, the websocket routing filter runs. It uses the Spring WebSocket infrastructure to forward the websocket request downstream.
You can load-balance websockets by prefixing the URI with `lb`, such as `lb:ws://serviceid`.
NOTE: If you use https://github.com/sockjs[SockJS] as a fallback over normal HTTP, you should configure a normal HTTP route as well as the websocket Route.
The following listing configures a websocket routing filter:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
# SockJS route
- id: websocket_sockjs_route
uri: http://localhost:3001
predicates:
- Path=/websocket/info/**
# Normal Websocket route
- id: websocket_route
uri: ws://localhost:3001
predicates:
- Path=/websocket/**
----
[[marking-an-exchange-as-routed]]
== Marking An Exchange As Routed
After the gateway has routed a `ServerWebExchange`, it marks that exchange as "`routed`" by adding `gatewayAlreadyRouted`
to the exchange attributes. Once a request has been marked as routed, other routing filters will not route the request again,
essentially skipping the filter. There are convenience methods that you can use to mark an exchange as routed
or check if an exchange has already been routed.
* `ServerWebExchangeUtils.isAlreadyRouted` takes a `ServerWebExchange` object and checks if it has been "`routed`".
* `ServerWebExchangeUtils.setAlreadyRouted` takes a `ServerWebExchange` object and marks it as "`routed`".

11
docs/modules/ROOT/pages/spring-cloud-gateway/glossary.adoc

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
[[glossary]]
= Glossary
:page-section-summary-toc: 1
* *Route*: The basic building block of the gateway.
It is defined by an ID, a destination URI, a collection of predicates, and a collection of filters. A route is matched if the aggregate predicate is true.
* *Predicate*: This is a https://docs.oracle.com/javase/8/docs/api/java/util/function/Predicate.html[Java 8 Function Predicate]. The input type is a https://docs.spring.io/spring/docs/5.0.x/javadoc-api/org/springframework/web/server/ServerWebExchange.html[Spring Framework `ServerWebExchange`].
This lets you match on anything from the HTTP request, such as headers or parameters.
* *Filter*: These are instances of {github-code}/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/GatewayFilter.java[`GatewayFilter`] that have been constructed with a specific factory.
Here, you can modify requests and responses before or after sending the downstream request.

15
docs/modules/ROOT/pages/spring-cloud-gateway/how-it-works.adoc

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
[[gateway-how-it-works]]
= How It Works
:page-section-summary-toc: 1
The following diagram provides a high-level overview of how Spring Cloud Gateway works:
image::spring_cloud_gateway_diagram.png[Spring Cloud Gateway Diagram]
Clients make requests to Spring Cloud Gateway. If the Gateway Handler Mapping determines that a request matches a route, it is sent to the Gateway Web Handler.
This handler runs the request through a filter chain that is specific to the request.
The reason the filters are divided by the dotted line is that filters can run logic both before and after the proxy request is sent.
All "`pre`" filter logic is executed. Then the proxy request is made. After the proxy request is made, the "`post`" filter logic is run.
NOTE: URIs defined in routes without a port get default port values of 80 and 443 for the HTTP and HTTPS URIs, respectively.

75
docs/modules/ROOT/pages/spring-cloud-gateway/http-timeouts-configuration.adoc

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
[[http-timeouts-configuration]]
= Http timeouts configuration
Http timeouts (response and connect) can be configured for all routes and overridden for each specific route.
[[global-timeouts]]
== Global timeouts
To configure Global http timeouts: +
`connect-timeout` must be specified in milliseconds. +
`response-timeout` must be specified as a java.time.Duration
.global http timeouts example
[source,yaml]
----
spring:
cloud:
gateway:
httpclient:
connect-timeout: 1000
response-timeout: 5s
----
[[per-route-timeouts]]
== Per-route timeouts
To configure per-route timeouts: +
`connect-timeout` must be specified in milliseconds. +
`response-timeout` must be specified in milliseconds.
.per-route http timeouts configuration via configuration
[source,yaml]
----
- id: per_route_timeouts
uri: https://example.org
predicates:
- name: Path
args:
pattern: /delay/{timeout}
metadata:
response-timeout: 200
connect-timeout: 200
----
.per-route timeouts configuration using Java DSL
[source,java]
----
import static org.springframework.cloud.gateway.support.RouteMetadataUtils.CONNECT_TIMEOUT_ATTR;
import static org.springframework.cloud.gateway.support.RouteMetadataUtils.RESPONSE_TIMEOUT_ATTR;
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder routeBuilder){
return routeBuilder.routes()
.route("test1", r -> {
return r.host("*.somehost.org").and().path("/somepath")
.filters(f -> f.addRequestHeader("header1", "header-value-1"))
.uri("http://someuri")
.metadata(RESPONSE_TIMEOUT_ATTR, 200)
.metadata(CONNECT_TIMEOUT_ATTR, 200);
})
.build();
}
----
A per-route `response-timeout` with a negative value will disable the global `response-timeout` value.
----
- id: per_route_timeouts
uri: https://example.org
predicates:
- name: Path
args:
pattern: /delay/{timeout}
metadata:
response-timeout: -1
----

45
docs/modules/ROOT/pages/spring-cloud-gateway/httpheadersfilters.adoc

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
[[httpheadersfilters]]
= HttpHeadersFilters
`HttpHeadersFilters` are applied to the requests before sending them downstream, such as in the `NettyRoutingFilter`.
[[forwarded-headers-filter]]
== Forwarded Headers Filter
The `Forwarded` Headers Filter creates a `Forwarded` header to send to the downstream service. It adds the `Host` header, scheme and port of the current request to any existing `Forwarded` header.
[[removehopbyhop-headers-filter]]
== RemoveHopByHop Headers Filter
The `RemoveHopByHop` Headers Filter removes headers from forwarded requests. The default list of headers that is removed comes from the https://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-7.1.3[IETF].
.The default removed headers are:
* Connection
* Keep-Alive
* Proxy-Authenticate
* Proxy-Authorization
* TE
* Trailer
* Transfer-Encoding
* Upgrade
To change this, set the `spring.cloud.gateway.filter.remove-hop-by-hop.headers` property to the list of header names to remove.
[[xforwarded-headers-filter]]
== XForwarded Headers Filter
The `XForwarded` Headers Filter creates various `X-Forwarded-*` headers to send to the downstream service. It uses the `Host` header, scheme, port and path of the current request to create the various headers.
Creating of individual headers can be controlled by the following boolean properties (defaults to true):
- `spring.cloud.gateway.x-forwarded.for-enabled`
- `spring.cloud.gateway.x-forwarded.host-enabled`
- `spring.cloud.gateway.x-forwarded.port-enabled`
- `spring.cloud.gateway.x-forwarded.proto-enabled`
- `spring.cloud.gateway.x-forwarded.prefix-enabled`
Appending multiple headers can be controlled by the following boolean properties (defaults to true):
- `spring.cloud.gateway.x-forwarded.for-append`
- `spring.cloud.gateway.x-forwarded.host-append`
- `spring.cloud.gateway.x-forwarded.port-append`
- `spring.cloud.gateway.x-forwarded.proto-append`
- `spring.cloud.gateway.x-forwarded.prefix-append`

27
docs/modules/ROOT/pages/spring-cloud-gateway/reactor-netty-access-logs.adoc

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
[[reactor-netty-access-logs]]
= Reactor Netty Access Logs
To enable Reactor Netty access logs, set `-Dreactor.netty.http.server.accessLogEnabled=true`.
IMPORTANT: It must be a Java System Property, not a Spring Boot property.
You can configure the logging system to have a separate access log file. The following example creates a Logback configuration:
.logback.xml
[source,xml]
----
<appender name="accessLog" class="ch.qos.logback.core.FileAppender">
<file>access_log.log</file>
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
<appender name="async" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="accessLog" />
</appender>
<logger name="reactor.netty.http.server.AccessLog" level="INFO" additivity="false">
<appender-ref ref="async"/>
</logger>
----

376
docs/modules/ROOT/pages/spring-cloud-gateway/request-predicates-factories.adoc

@ -0,0 +1,376 @@ @@ -0,0 +1,376 @@
[[gateway-request-predicates-factories]]
= Route Predicate Factories
Spring Cloud Gateway matches routes as part of the Spring WebFlux `HandlerMapping` infrastructure.
Spring Cloud Gateway includes many built-in route predicate factories.
All of these predicates match on different attributes of the HTTP request.
You can combine multiple route predicate factories with logical `and` statements.
[[after-route-predicate-factory]]
== The After Route Predicate Factory
The `After` route predicate factory takes one parameter, a `datetime` (which is a java `ZonedDateTime`).
This predicate matches requests that happen after the specified datetime.
The following example configures an after route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: after_route
uri: https://example.org
predicates:
- After=2017-01-20T17:42:47.789-07:00[America/Denver]
----
This route matches any request made after Jan 20, 2017 17:42 Mountain Time (Denver).
[[before-route-predicate-factory]]
== The Before Route Predicate Factory
The `Before` route predicate factory takes one parameter, a `datetime` (which is a java `ZonedDateTime`).
This predicate matches requests that happen before the specified `datetime`.
The following example configures a before route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: before_route
uri: https://example.org
predicates:
- Before=2017-01-20T17:42:47.789-07:00[America/Denver]
----
This route matches any request made before Jan 20, 2017 17:42 Mountain Time (Denver).
[[between-route-predicate-factory]]
== The Between Route Predicate Factory
The `Between` route predicate factory takes two parameters, `datetime1` and `datetime2`
which are java `ZonedDateTime` objects.
This predicate matches requests that happen after `datetime1` and before `datetime2`.
The `datetime2` parameter must be after `datetime1`.
The following example configures a between route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: between_route
uri: https://example.org
predicates:
- Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]
----
This route matches any request made after Jan 20, 2017 17:42 Mountain Time (Denver) and before Jan 21, 2017 17:42 Mountain Time (Denver).
This could be useful for maintenance windows.
[[cookie-route-predicate-factory]]
== The Cookie Route Predicate Factory
The `Cookie` route predicate factory takes two parameters, the cookie `name` and a `regexp` (which is a Java regular expression).
This predicate matches cookies that have the given name and whose values match the regular expression.
The following example configures a cookie route predicate factory:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: cookie_route
uri: https://example.org
predicates:
- Cookie=chocolate, ch.p
----
This route matches requests that have a cookie named `chocolate` whose value matches the `ch.p` regular expression.
[[header-route-predicate-factory]]
== The Header Route Predicate Factory
The `Header` route predicate factory takes two parameters, the `header` and a `regexp` (which is a Java regular expression).
This predicate matches with a header that has the given name whose value matches the regular expression.
The following example configures a header route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: header_route
uri: https://example.org
predicates:
- Header=X-Request-Id, \d+
----
This route matches if the request has a header named `X-Request-Id` whose value matches the `\d+` regular expression (that is, it has a value of one or more digits).
[[host-route-predicate-factory]]
== The Host Route Predicate Factory
The `Host` route predicate factory takes one parameter: a list of host name `patterns`.
The pattern is an Ant-style pattern with `.` as the separator.
This predicates matches the `Host` header that matches the pattern.
The following example configures a host route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: host_route
uri: https://example.org
predicates:
- Host=**.somehost.org,**.anotherhost.org
----
URI template variables (such as `\{sub}.myhost.org`) are supported as well.
This route matches if the request has a `Host` header with a value of `www.somehost.org` or `beta.somehost.org` or `www.anotherhost.org`.
This predicate extracts the URI template variables (such as `sub`, defined in the preceding example) as a map of names and values and places it in the `ServerWebExchange.getAttributes()` with a key defined in `ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE`.
Those values are then available for use by <<gateway-route-filters,`GatewayFilter` factories>>
[[method-route-predicate-factory]]
== The Method Route Predicate Factory
The `Method` Route Predicate Factory takes a `methods` argument which is one or more parameters: the HTTP methods to match.
The following example configures a method route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: method_route
uri: https://example.org
predicates:
- Method=GET,POST
----
This route matches if the request method was a `GET` or a `POST`.
[[path-route-predicate-factory]]
== The Path Route Predicate Factory
The `Path` Route Predicate Factory takes two parameters: a list of Spring `PathMatcher` `patterns` and an optional flag called `matchTrailingSlash` (defaults to `true`).
The following example configures a path route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: path_route
uri: https://example.org
predicates:
- Path=/red/{segment},/blue/{segment}
----
This route matches if the request path was, for example: `/red/1` or `/red/1/` or `/red/blue` or `/blue/green`.
If `matchTrailingSlash` is set to `false`, then request path `/red/1/` will not be matched.
This predicate extracts the URI template variables (such as `segment`, defined in the preceding example) as a map of names and values and places it in the `ServerWebExchange.getAttributes()` with a key defined in `ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE`.
Those values are then available for use by <<gateway-route-filters,`GatewayFilter` factories>>
A utility method (called `get`) is available to make access to these variables easier.
The following example shows how to use the `get` method:
[source,java]
----
Map<String, String> uriVariables = ServerWebExchangeUtils.getUriTemplateVariables(exchange);
String segment = uriVariables.get("segment");
----
[[query-route-predicate-factory]]
== The Query Route Predicate Factory
The `Query` route predicate factory takes two parameters: a required `param` and an optional `regexp` (which is a Java regular expression).
The following example configures a query route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: query_route
uri: https://example.org
predicates:
- Query=green
----
The preceding route matches if the request contained a `green` query parameter.
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: query_route
uri: https://example.org
predicates:
- Query=red, gree.
----
The preceding route matches if the request contained a `red` query parameter whose value matched the `gree.` regexp, so `green` and `greet` would match.
[[remoteaddr-route-predicate-factory]]
== The RemoteAddr Route Predicate Factory
The `RemoteAddr` route predicate factory takes a list (min size 1) of `sources`, which are CIDR-notation (IPv4 or IPv6) strings, such as `192.168.0.1/16` (where `192.168.0.1` is an IP address and `16` is a subnet mask).
The following example configures a RemoteAddr route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: remoteaddr_route
uri: https://example.org
predicates:
- RemoteAddr=192.168.1.1/24
----
This route matches if the remote address of the request was, for example, `192.168.1.10`.
[[modifying-the-way-remote-addresses-are-resolved]]
=== Modifying the Way Remote Addresses Are Resolved
By default, the RemoteAddr route predicate factory uses the remote address from the incoming request.
This may not match the actual client IP address if Spring Cloud Gateway sits behind a proxy layer.
You can customize the way that the remote address is resolved by setting a custom `RemoteAddressResolver`.
Spring Cloud Gateway comes with one non-default remote address resolver that is based off of the https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For[X-Forwarded-For header], `XForwardedRemoteAddressResolver`.
`XForwardedRemoteAddressResolver` has two static constructor methods, which take different approaches to security:
* `XForwardedRemoteAddressResolver::trustAll` returns a `RemoteAddressResolver` that always takes the first IP address found in the `X-Forwarded-For` header.
This approach is vulnerable to spoofing, as a malicious client could set an initial value for the `X-Forwarded-For`, which would be accepted by the resolver.
* `XForwardedRemoteAddressResolver::maxTrustedIndex` takes an index that correlates to the number of trusted infrastructure running in front of Spring Cloud Gateway.
If Spring Cloud Gateway is, for example only accessible through HAProxy, then a value of 1 should be used.
If two hops of trusted infrastructure are required before Spring Cloud Gateway is accessible, then a value of 2 should be used.
Consider the following header value:
[source]
----
X-Forwarded-For: 0.0.0.1, 0.0.0.2, 0.0.0.3
----
The following `maxTrustedIndex` values yield the following remote addresses:
[options="header"]
|===
|`maxTrustedIndex` | result
|[`Integer.MIN_VALUE`,0] | (invalid, `IllegalArgumentException` during initialization)
|1 | 0.0.0.3
|2 | 0.0.0.2
|3 | 0.0.0.1
|[4, `Integer.MAX_VALUE`] | 0.0.0.1
|===
[[gateway-route-filters]]
The following example shows how to achieve the same configuration with Java:
.GatewayConfig.java
[source,java]
----
RemoteAddressResolver resolver = XForwardedRemoteAddressResolver
.maxTrustedIndex(1);
...
.route("direct-route",
r -> r.remoteAddr("10.1.1.1", "10.10.1.1/24")
.uri("https://downstream1")
.route("proxied-route",
r -> r.remoteAddr(resolver, "10.10.1.1", "10.10.1.1/24")
.uri("https://downstream2")
)
----
[[weight-route-predicate-factory]]
== The Weight Route Predicate Factory
The `Weight` route predicate factory takes two arguments: `group` and `weight` (an int). The weights are calculated per group.
The following example configures a weight route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: weight_high
uri: https://weighthigh.org
predicates:
- Weight=group1, 8
- id: weight_low
uri: https://weightlow.org
predicates:
- Weight=group1, 2
----
This route would forward ~80% of traffic to https://weighthigh.org and ~20% of traffic to https://weightlow.org
[[xforwarded-remote-addr-route-predicate-factory]]
== The XForwarded Remote Addr Route Predicate Factory
The `XForwarded Remote Addr` route predicate factory takes a list (min size 1) of `sources`, which are CIDR-notation (IPv4 or IPv6) strings, such as `192.168.0.1/16` (where `192.168.0.1` is an IP address and `16` is a subnet mask).
This route predicate allows requests to be filtered based on the `X-Forwarded-For` HTTP header.
This can be used with reverse proxies such as load balancers or web application firewalls where
the request should only be allowed if it comes from a trusted list of IP addresses used by those
reverse proxies.
The following example configures a XForwardedRemoteAddr route predicate:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: xforwarded_remoteaddr_route
uri: https://example.org
predicates:
- XForwardedRemoteAddr=192.168.1.1/24
----
This route matches if the `X-Forwarded-For` header contains, for example, `192.168.1.10`.

32
docs/modules/ROOT/pages/spring-cloud-gateway/route-metadata-configuration.adoc

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
[[route-metadata-configuration]]
= Route Metadata Configuration
You can configure additional parameters for each route by using metadata, as follows:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
routes:
- id: route_with_metadata
uri: https://example.org
metadata:
optionName: "OptionValue"
compositeObject:
name: "value"
iAmNumber: 1
----
You could acquire all metadata properties from an exchange, as follows:
[source]
----
Route route = exchange.getAttribute(GATEWAY_ROUTE_ATTR);
// get all metadata properties
route.getMetadata();
// get a single metadata property
route.getMetadata(someKey);
----

16
docs/modules/ROOT/pages/spring-cloud-gateway/starter.adoc

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
[[gateway-starter]]
= How to Include Spring Cloud Gateway
:page-section-summary-toc: 1
To include Spring Cloud Gateway in your project, use the starter with a group ID of `org.springframework.cloud` and an artifact ID of `spring-cloud-starter-gateway`.
See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train.
If you include the starter, but you do not want the gateway to be enabled, set `spring.cloud.gateway.enabled=false`.
IMPORTANT: Spring Cloud Gateway is built on https://spring.io/projects/spring-boot#learn[Spring Boot], https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html[Spring WebFlux], and https://projectreactor.io/docs[Project Reactor].
As a consequence, many of the familiar synchronous libraries (Spring Data and Spring Security, for example) and patterns you know may not apply when you use Spring Cloud Gateway.
If you are unfamiliar with these projects, we suggest you begin by reading their documentation to familiarize yourself with some new concepts before working with Spring Cloud Gateway.
IMPORTANT: Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux.
It does not work in a traditional Servlet Container or when built as a WAR.

36
docs/modules/ROOT/pages/spring-cloud-gateway/the-discoveryclient-route-definition-locator.adoc

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
[[discoveryclient-route-definition-locator]]
= `DiscoveryClient` Route Definition Locator
You can configure the gateway to create routes based on services registered with a `DiscoveryClient` compatible service registry.
To enable this, set `spring.cloud.gateway.discovery.locator.enabled=true` and make sure a `DiscoveryClient` implementation (such as Netflix Eureka, Consul, or Zookeeper) is on the classpath and enabled.
[[configuring-predicates-and-filters-for-discoveryclient-routes]]
== Configuring Predicates and Filters For `DiscoveryClient` Routes
By default, the gateway defines a single predicate and filter for routes created with a `DiscoveryClient`.
The default predicate is a path predicate defined with the pattern `/serviceId/**`, where `serviceId` is
the ID of the service from the `DiscoveryClient`.
The default filter is a rewrite path filter with the regex `/serviceId/?(?<remaining>.*)` and the replacement `/$\{remaining}`.
This strips the service ID from the path before the request is sent downstream.
If you want to customize the predicates or filters used by the `DiscoveryClient` routes, set `spring.cloud.gateway.discovery.locator.predicates[x]` and `spring.cloud.gateway.discovery.locator.filters[y]`.
When doing so, you need to make sure to include the default predicate and filter shown earlier, if you want to retain that functionality.
The following example shows what this looks like:
.application.properties
[soure,properties]
----
spring.cloud.gateway.discovery.locator.predicates[0].name: Path
spring.cloud.gateway.discovery.locator.predicates[0].args[pattern]: "'/'+serviceId+'/**'"
spring.cloud.gateway.discovery.locator.predicates[1].name: Host
spring.cloud.gateway.discovery.locator.predicates[1].args[pattern]: "'**.foo.com'"
spring.cloud.gateway.discovery.locator.filters[0].name: CircuitBreaker
spring.cloud.gateway.discovery.locator.filters[0].args[name]: serviceId
spring.cloud.gateway.discovery.locator.filters[1].name: RewritePath
spring.cloud.gateway.discovery.locator.filters[1].args[regexp]: "'/' + serviceId + '/?(?<remaining>.*)'"
spring.cloud.gateway.discovery.locator.filters[1].args[replacement]: "'/$\{remaining}'"
----

71
docs/modules/ROOT/pages/spring-cloud-gateway/tls-and-ssl.adoc

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
[[tls-and-ssl]]
= TLS and SSL
The gateway can listen for requests on HTTPS by following the usual Spring server configuration.
The following example shows how to do so:
.application.yml
[source,yaml]
----
server:
ssl:
enabled: true
key-alias: scg
key-store-password: scg1234
key-store: classpath:scg-keystore.p12
key-store-type: PKCS12
----
You can route gateway routes to both HTTP and HTTPS backends.
If you are routing to an HTTPS backend, you can configure the gateway to trust all downstream certificates with the following configuration:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
httpclient:
ssl:
useInsecureTrustManager: true
----
Using an insecure trust manager is not suitable for production.
For a production deployment, you can configure the gateway with a set of known certificates that it can trust with the following configuration:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
httpclient:
ssl:
trustedX509Certificates:
- cert1.pem
- cert2.pem
----
If the Spring Cloud Gateway is not provisioned with trusted certificates, the default trust store is used (which you can override by setting the `javax.net.ssl.trustStore` system property).
[[tls-handshake]]
== TLS Handshake
The gateway maintains a client pool that it uses to route to backends.
When communicating over HTTPS, the client initiates a TLS handshake.
A number of timeouts are associated with this handshake.
You can configure these timeouts can be configured (defaults shown) as follows:
.application.yml
[source,yaml]
----
spring:
cloud:
gateway:
httpclient:
ssl:
handshake-timeout-millis: 10000
close-notify-flush-timeout-millis: 3000
close-notify-read-timeout-millis: 0
----

25
docs/modules/ROOT/pages/spring-cloud-gateway/troubleshooting.adoc

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
[[troubleshooting]]
= Troubleshooting
:page-section-summary-toc: 1
This section covers common problems that may arise when you use Spring Cloud Gateway.
[[log-levels]]
== Log Levels
The following loggers may contain valuable troubleshooting information at the `DEBUG` and `TRACE` levels:
- `org.springframework.cloud.gateway`
- `org.springframework.http.server.reactive`
- `org.springframework.web.reactive`
- `org.springframework.boot.autoconfigure.web`
- `reactor.netty`
- `redisratelimiter`
[[wiretap]]
== Wiretap
The Reactor Netty `HttpClient` and `HttpServer` can have wiretap enabled.
When combined with setting the `reactor.netty` log level to `DEBUG` or `TRACE`, it enables the logging of information, such as headers and bodies sent and received across the wire.
To enable wiretap, set `spring.cloud.gateway.httpserver.wiretap=true` or `spring.cloud.gateway.httpclient.wiretap=true` for the `HttpServer` and `HttpClient`, respectively.

156
docs/modules/ROOT/partials/_configprops.adoc

@ -0,0 +1,156 @@ @@ -0,0 +1,156 @@
|===
|Name | Default | Description
|spring.cloud.gateway.default-filters | | List of filter definitions that are applied to every route.
|spring.cloud.gateway.discovery.locator.enabled | `+++false+++` | Flag that enables DiscoveryClient gateway integration.
|spring.cloud.gateway.discovery.locator.filters | |
|spring.cloud.gateway.discovery.locator.include-expression | `+++true+++` | SpEL expression that will evaluate whether to include a service in gateway integration or not, defaults to: true.
|spring.cloud.gateway.discovery.locator.lower-case-service-id | `+++false+++` | Option to lower case serviceId in predicates and filters, defaults to false. Useful with eureka when it automatically uppercases serviceId. so MYSERIVCE, would match /myservice/**
|spring.cloud.gateway.discovery.locator.predicates | |
|spring.cloud.gateway.discovery.locator.route-id-prefix | | The prefix for the routeId, defaults to discoveryClient.getClass().getSimpleName() + "_". Service Id will be appended to create the routeId.
|spring.cloud.gateway.discovery.locator.url-expression | `+++'lb://'+serviceId+++` | SpEL expression that create the uri for each route, defaults to: 'lb://'+serviceId.
|spring.cloud.gateway.enabled | `+++true+++` | Enables gateway functionality.
|spring.cloud.gateway.fail-on-route-definition-error | `+++true+++` | Option to fail on route definition errors, defaults to true. Otherwise, a warning is logged.
|spring.cloud.gateway.filter.add-request-header.enabled | `+++true+++` | Enables the add-request-header filter.
|spring.cloud.gateway.filter.add-request-parameter.enabled | `+++true+++` | Enables the add-request-parameter filter.
|spring.cloud.gateway.filter.add-response-header.enabled | `+++true+++` | Enables the add-response-header filter.
|spring.cloud.gateway.filter.circuit-breaker.enabled | `+++true+++` | Enables the circuit-breaker filter.
|spring.cloud.gateway.filter.dedupe-response-header.enabled | `+++true+++` | Enables the dedupe-response-header filter.
|spring.cloud.gateway.filter.fallback-headers.enabled | `+++true+++` | Enables the fallback-headers filter.
|spring.cloud.gateway.filter.hystrix.enabled | `+++true+++` | Enables the hystrix filter.
|spring.cloud.gateway.filter.json-to-grpc.enabled | `+++true+++` | Enables the JSON to gRPC filter.
|spring.cloud.gateway.filter.local-response-cache.enabled | `+++false+++` | Enables the local-response-cache filter.
|spring.cloud.gateway.filter.local-response-cache.request.no-cache-strategy | |
|spring.cloud.gateway.filter.local-response-cache.size | | Maximum size of the cache to evict entries for this route (in KB, MB and GB).
|spring.cloud.gateway.filter.local-response-cache.time-to-live | `+++5m+++` | Time to expire a cache entry (expressed in s for seconds, m for minutes, and h for hours).
|spring.cloud.gateway.filter.map-request-header.enabled | `+++true+++` | Enables the map-request-header filter.
|spring.cloud.gateway.filter.modify-request-body.enabled | `+++true+++` | Enables the modify-request-body filter.
|spring.cloud.gateway.filter.modify-response-body.enabled | `+++true+++` | Enables the modify-response-body filter.
|spring.cloud.gateway.filter.prefix-path.enabled | `+++true+++` | Enables the prefix-path filter.
|spring.cloud.gateway.filter.preserve-host-header.enabled | `+++true+++` | Enables the preserve-host-header filter.
|spring.cloud.gateway.filter.redirect-to.enabled | `+++true+++` | Enables the redirect-to filter.
|spring.cloud.gateway.filter.remove-hop-by-hop.headers | |
|spring.cloud.gateway.filter.remove-hop-by-hop.order | `+++0+++` |
|spring.cloud.gateway.filter.remove-request-header.enabled | `+++true+++` | Enables the remove-request-header filter.
|spring.cloud.gateway.filter.remove-request-parameter.enabled | `+++true+++` | Enables the remove-request-parameter filter.
|spring.cloud.gateway.filter.remove-response-header.enabled | `+++true+++` | Enables the remove-response-header filter.
|spring.cloud.gateway.filter.request-header-size.enabled | `+++true+++` | Enables the request-header-size filter.
|spring.cloud.gateway.filter.request-header-to-request-uri.enabled | `+++true+++` | Enables the request-header-to-request-uri filter.
|spring.cloud.gateway.filter.request-rate-limiter.default-key-resolver | |
|spring.cloud.gateway.filter.request-rate-limiter.default-rate-limiter | |
|spring.cloud.gateway.filter.request-rate-limiter.enabled | `+++true+++` | Enables the request-rate-limiter filter.
|spring.cloud.gateway.filter.request-size.enabled | `+++true+++` | Enables the request-size filter.
|spring.cloud.gateway.filter.retry.enabled | `+++true+++` | Enables the retry filter.
|spring.cloud.gateway.filter.rewrite-location-response-header.enabled | `+++true+++` | Enables the rewrite-location-response-header filter.
|spring.cloud.gateway.filter.rewrite-location.enabled | `+++true+++` | Enables the rewrite-location filter.
|spring.cloud.gateway.filter.rewrite-path.enabled | `+++true+++` | Enables the rewrite-path filter.
|spring.cloud.gateway.filter.rewrite-request-parameter.enabled | `+++true+++` | Enables the rewrite-request-parameter filter.
|spring.cloud.gateway.filter.rewrite-response-header.enabled | `+++true+++` | Enables the rewrite-response-header filter.
|spring.cloud.gateway.filter.save-session.enabled | `+++true+++` | Enables the save-session filter.
|spring.cloud.gateway.filter.secure-headers.content-security-policy | `+++default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'+++` |
|spring.cloud.gateway.filter.secure-headers.content-type-options | `+++nosniff+++` |
|spring.cloud.gateway.filter.secure-headers.disable | |
|spring.cloud.gateway.filter.secure-headers.download-options | `+++noopen+++` |
|spring.cloud.gateway.filter.secure-headers.enabled | `+++true+++` | Enables the secure-headers filter.
|spring.cloud.gateway.filter.secure-headers.frame-options | `+++DENY+++` |
|spring.cloud.gateway.filter.secure-headers.permitted-cross-domain-policies | `+++none+++` |
|spring.cloud.gateway.filter.secure-headers.referrer-policy | `+++no-referrer+++` |
|spring.cloud.gateway.filter.secure-headers.strict-transport-security | `+++max-age=631138519+++` |
|spring.cloud.gateway.filter.secure-headers.xss-protection-header | `+++1 ; mode=block+++` |
|spring.cloud.gateway.filter.set-path.enabled | `+++true+++` | Enables the set-path filter.
|spring.cloud.gateway.filter.set-request-header.enabled | `+++true+++` | Enables the set-request-header filter.
|spring.cloud.gateway.filter.set-request-host-header.enabled | `+++true+++` | Enables the set-request-host-header filter.
|spring.cloud.gateway.filter.set-response-header.enabled | `+++true+++` | Enables the set-response-header filter.
|spring.cloud.gateway.filter.set-status.enabled | `+++true+++` | Enables the set-status filter.
|spring.cloud.gateway.filter.strip-prefix.enabled | `+++true+++` | Enables the strip-prefix filter.
|spring.cloud.gateway.forwarded.enabled | `+++true+++` | Enables the ForwardedHeadersFilter.
|spring.cloud.gateway.global-filter.adapt-cached-body.enabled | `+++true+++` | Enables the adapt-cached-body global filter.
|spring.cloud.gateway.global-filter.forward-path.enabled | `+++true+++` | Enables the forward-path global filter.
|spring.cloud.gateway.global-filter.forward-routing.enabled | `+++true+++` | Enables the forward-routing global filter.
|spring.cloud.gateway.global-filter.load-balancer-client.enabled | `+++true+++` | Enables the load-balancer-client global filter.
|spring.cloud.gateway.global-filter.local-response-cache.enabled | `+++true+++` | Enables the local-response-cache filter for all routes, it allows to add a specific configuration at route level using LocalResponseCache filter.
|spring.cloud.gateway.global-filter.netty-routing.enabled | `+++true+++` | Enables the netty-routing global filter.
|spring.cloud.gateway.global-filter.netty-write-response.enabled | `+++true+++` | Enables the netty-write-response global filter.
|spring.cloud.gateway.global-filter.reactive-load-balancer-client.enabled | `+++true+++` | Enables the reactive-load-balancer-client global filter.
|spring.cloud.gateway.global-filter.remove-cached-body.enabled | `+++true+++` | Enables the remove-cached-body global filter.
|spring.cloud.gateway.global-filter.route-to-request-url.enabled | `+++true+++` | Enables the route-to-request-url global filter.
|spring.cloud.gateway.global-filter.websocket-routing.enabled | `+++true+++` | Enables the websocket-routing global filter.
|spring.cloud.gateway.globalcors.add-to-simple-url-handler-mapping | `+++false+++` | If global CORS config should be added to the URL handler.
|spring.cloud.gateway.globalcors.cors-configurations | |
|spring.cloud.gateway.handler-mapping.order | `+++1+++` | The order of RoutePredicateHandlerMapping.
|spring.cloud.gateway.httpclient.compression | `+++false+++` | Enables compression for Netty HttpClient.
|spring.cloud.gateway.httpclient.connect-timeout | | The connect timeout in millis, the default is 30s.
|spring.cloud.gateway.httpclient.max-header-size | | The max response header size.
|spring.cloud.gateway.httpclient.max-initial-line-length | | The max initial line length.
|spring.cloud.gateway.httpclient.pool.acquire-timeout | | Only for type FIXED, the maximum time in millis to wait for acquiring.
|spring.cloud.gateway.httpclient.pool.eviction-interval | `+++0+++` | Perform regular eviction checks in the background at a specified interval. Disabled by default ({@link Duration#ZERO})
|spring.cloud.gateway.httpclient.pool.max-connections | | Only for type FIXED, the maximum number of connections before starting pending acquisition on existing ones.
|spring.cloud.gateway.httpclient.pool.max-idle-time | | Time in millis after which the channel will be closed. If NULL, there is no max idle time.
|spring.cloud.gateway.httpclient.pool.max-life-time | | Duration after which the channel will be closed. If NULL, there is no max life time.
|spring.cloud.gateway.httpclient.pool.metrics | `+++false+++` | Enables channel pools metrics to be collected and registered in Micrometer. Disabled by default.
|spring.cloud.gateway.httpclient.pool.name | `+++proxy+++` | The channel pool map name, defaults to proxy.
|spring.cloud.gateway.httpclient.pool.type | | Type of pool for HttpClient to use, defaults to ELASTIC.
|spring.cloud.gateway.httpclient.proxy.host | | Hostname for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.proxy.non-proxy-hosts-pattern | | Regular expression (Java) for a configured list of hosts. that should be reached directly, bypassing the proxy
|spring.cloud.gateway.httpclient.proxy.password | | Password for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.proxy.port | | Port for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.proxy.type | | proxyType for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.proxy.username | | Username for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.response-timeout | | The response timeout.
|spring.cloud.gateway.httpclient.ssl.close-notify-flush-timeout | `+++3000ms+++` | SSL close_notify flush timeout. Default to 3000 ms.
|spring.cloud.gateway.httpclient.ssl.close-notify-read-timeout | `+++0+++` | SSL close_notify read timeout. Default to 0 ms.
|spring.cloud.gateway.httpclient.ssl.handshake-timeout | `+++10000ms+++` | SSL handshake timeout. Default to 10000 ms
|spring.cloud.gateway.httpclient.ssl.key-password | | Key password, default is same as keyStorePassword.
|spring.cloud.gateway.httpclient.ssl.key-store | | Keystore path for Netty HttpClient.
|spring.cloud.gateway.httpclient.ssl.key-store-password | | Keystore password.
|spring.cloud.gateway.httpclient.ssl.key-store-provider | | Keystore provider for Netty HttpClient, optional field.
|spring.cloud.gateway.httpclient.ssl.key-store-type | `+++JKS+++` | Keystore type for Netty HttpClient, default is JKS.
|spring.cloud.gateway.httpclient.ssl.trusted-x509-certificates | | Trusted certificates for verifying the remote endpoint's certificate.
|spring.cloud.gateway.httpclient.ssl.use-insecure-trust-manager | `+++false+++` | Installs the netty InsecureTrustManagerFactory. This is insecure and not suitable for production.
|spring.cloud.gateway.httpclient.websocket.max-frame-payload-length | | Max frame payload length.
|spring.cloud.gateway.httpclient.websocket.proxy-ping | `+++true+++` | Proxy ping frames to downstream services, defaults to true.
|spring.cloud.gateway.httpclient.wiretap | `+++false+++` | Enables wiretap debugging for Netty HttpClient.
|spring.cloud.gateway.httpserver.wiretap | `+++false+++` | Enables wiretap debugging for Netty HttpServer.
|spring.cloud.gateway.loadbalancer.use404 | `+++false+++` |
|spring.cloud.gateway.metrics.enabled | `+++false+++` | Enables the collection of metrics data.
|spring.cloud.gateway.metrics.prefix | `+++spring.cloud.gateway+++` | The prefix of all metrics emitted by gateway.
|spring.cloud.gateway.metrics.tags | | Tags map that added to metrics.
|spring.cloud.gateway.observability.enabled | `+++true+++` | If Micrometer Observability support should be turned on.
|spring.cloud.gateway.predicate.after.enabled | `+++true+++` | Enables the after predicate.
|spring.cloud.gateway.predicate.before.enabled | `+++true+++` | Enables the before predicate.
|spring.cloud.gateway.predicate.between.enabled | `+++true+++` | Enables the between predicate.
|spring.cloud.gateway.predicate.cloud-foundry-route-service.enabled | `+++true+++` | Enables the cloud-foundry-route-service predicate.
|spring.cloud.gateway.predicate.cookie.enabled | `+++true+++` | Enables the cookie predicate.
|spring.cloud.gateway.predicate.header.enabled | `+++true+++` | Enables the header predicate.
|spring.cloud.gateway.predicate.host.enabled | `+++true+++` | Enables the host predicate.
|spring.cloud.gateway.predicate.method.enabled | `+++true+++` | Enables the method predicate.
|spring.cloud.gateway.predicate.path.enabled | `+++true+++` | Enables the path predicate.
|spring.cloud.gateway.predicate.query.enabled | `+++true+++` | Enables the query predicate.
|spring.cloud.gateway.predicate.read-body.enabled | `+++true+++` | Enables the read-body predicate.
|spring.cloud.gateway.predicate.remote-addr.enabled | `+++true+++` | Enables the remote-addr predicate.
|spring.cloud.gateway.predicate.weight.enabled | `+++true+++` | Enables the weight predicate.
|spring.cloud.gateway.predicate.xforwarded-remote-addr.enabled | `+++true+++` | Enables the xforwarded-remote-addr predicate.
|spring.cloud.gateway.redis-rate-limiter.burst-capacity-header | `+++X-RateLimit-Burst-Capacity+++` | The name of the header that returns the burst capacity configuration.
|spring.cloud.gateway.redis-rate-limiter.config | |
|spring.cloud.gateway.redis-rate-limiter.include-headers | `+++true+++` | Whether or not to include headers containing rate limiter information, defaults to true.
|spring.cloud.gateway.redis-rate-limiter.remaining-header | `+++X-RateLimit-Remaining+++` | The name of the header that returns number of remaining requests during the current second.
|spring.cloud.gateway.redis-rate-limiter.replenish-rate-header | `+++X-RateLimit-Replenish-Rate+++` | The name of the header that returns the replenish rate configuration.
|spring.cloud.gateway.redis-rate-limiter.requested-tokens-header | `+++X-RateLimit-Requested-Tokens+++` | The name of the header that returns the requested tokens configuration.
|spring.cloud.gateway.restrictive-property-accessor.enabled | `+++true+++` | Restricts method and property access in SpEL.
|spring.cloud.gateway.routes | | List of Routes.
|spring.cloud.gateway.set-status.original-status-header-name | | The name of the header which contains http code of the proxied request.
|spring.cloud.gateway.streaming-media-types | |
|spring.cloud.gateway.x-forwarded.enabled | `+++true+++` | If the XForwardedHeadersFilter is enabled.
|spring.cloud.gateway.x-forwarded.for-append | `+++true+++` | If appending X-Forwarded-For as a list is enabled.
|spring.cloud.gateway.x-forwarded.for-enabled | `+++true+++` | If X-Forwarded-For is enabled.
|spring.cloud.gateway.x-forwarded.host-append | `+++true+++` | If appending X-Forwarded-Host as a list is enabled.
|spring.cloud.gateway.x-forwarded.host-enabled | `+++true+++` | If X-Forwarded-Host is enabled.
|spring.cloud.gateway.x-forwarded.order | `+++0+++` | The order of the XForwardedHeadersFilter.
|spring.cloud.gateway.x-forwarded.port-append | `+++true+++` | If appending X-Forwarded-Port as a list is enabled.
|spring.cloud.gateway.x-forwarded.port-enabled | `+++true+++` | If X-Forwarded-Port is enabled.
|spring.cloud.gateway.x-forwarded.prefix-append | `+++true+++` | If appending X-Forwarded-Prefix as a list is enabled.
|spring.cloud.gateway.x-forwarded.prefix-enabled | `+++true+++` | If X-Forwarded-Prefix is enabled.
|spring.cloud.gateway.x-forwarded.proto-append | `+++true+++` | If appending X-Forwarded-Proto as a list is enabled.
|spring.cloud.gateway.x-forwarded.proto-enabled | `+++true+++` | If X-Forwarded-Proto is enabled.
|===

11
docs/modules/ROOT/partials/_conventions.adoc

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
[[observability-conventions]]
=== Observability - Conventions
Below you can find a list of all `GlobalObservationConvention` and `ObservationConvention` declared by this project.
.ObservationConvention implementations
|===
|ObservationConvention Class Name | Applicable ObservationContext Class Name
|`org.springframework.cloud.gateway.filter.headers.observation.DefaultGatewayObservationConvention`|`GatewayContext`
|`org.springframework.cloud.gateway.filter.headers.observation.GatewayObservationConvention`|`GatewayContext`
|===

46
docs/modules/ROOT/partials/_metrics.adoc

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
[[observability-metrics]]
=== Observability - Metrics
Below you can find a list of all metrics declared by this project.
[[observability-metrics-gateway-http-client-observation]]
==== Gateway Http Client Observation
____
Observation created when sending a request through the gateway.
____
**Metric name** `http.client.requests` (defined by convention class `org.springframework.cloud.gateway.filter.headers.observation.DefaultGatewayObservationConvention`). **Type** `timer`.
**Metric name** `http.client.requests.active` (defined by convention class `org.springframework.cloud.gateway.filter.headers.observation.DefaultGatewayObservationConvention`). **Type** `long task timer`.
IMPORTANT: KeyValues that are added after starting the Observation might be missing from the *.active metrics.
IMPORTANT: Micrometer internally uses `nanoseconds` for the baseunit. However, each backend determines the actual baseunit. (i.e. Prometheus uses seconds)
Fully qualified name of the enclosing class `org.springframework.cloud.gateway.filter.headers.observation.GatewayDocumentedObservation`.
.Low cardinality Keys
[cols="a,a"]
|===
|Name | Description
|`http.method` _(required)_|HTTP Method.
|`http.status_code` _(required)_|HTTP Status.
|`spring.cloud.gateway.route.id` _(required)_|Route ID.
|`spring.cloud.gateway.route.uri` _(required)_|HTTP URI taken from the Route.
|===
.High cardinality Keys
[cols="a,a"]
|===
|Name | Description
|`http.uri` _(required)_|Full HTTP URI.
|===

29
docs/modules/ROOT/partials/_spans.adoc

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
[[observability-spans]]
=== Observability - Spans
Below you can find a list of all spans declared by this project.
[[observability-spans-gateway-http-client-observation]]
==== Gateway Http Client Observation Span
> Observation created when sending a request through the gateway.
**Span name** `http.client.requests` (defined by convention class `org.springframework.cloud.gateway.filter.headers.observation.DefaultGatewayObservationConvention`).
Fully qualified name of the enclosing class `org.springframework.cloud.gateway.filter.headers.observation.GatewayDocumentedObservation`.
.Tag Keys
|===
|Name | Description
|`http.method` _(required)_|HTTP Method.
|`http.status_code` _(required)_|HTTP Status.
|`http.uri` _(required)_|Full HTTP URI.
|`spring.cloud.gateway.route.id` _(required)_|Route ID.
|`spring.cloud.gateway.route.uri` _(required)_|HTTP URI taken from the Route.
|===

53
docs/pom.xml

@ -6,17 +6,24 @@ @@ -6,17 +6,24 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>4.1.0-SNAPSHOT</version>
</parent>
<artifactId>spring-cloud-gateway-docs</artifactId>
<packaging>jar</packaging>
<name>Spring Cloud Gateway Docs</name>
<description>Spring Cloud Docs</description>
<description>Spring Cloud Gateway Docs</description>
<properties>
<docs.main>spring-cloud-gateway</docs.main>
<main.basedir>${basedir}/..</main.basedir>
<configprops.inclusionPattern>spring.cloud.gateway.*</configprops.inclusionPattern>
<upload-docs-zip.phase>deploy</upload-docs-zip.phase>
<!-- Don't upload docs jar to central / repo.spring.io -->
<maven-deploy-plugin-default.phase>none</maven-deploy-plugin-default.phase>
<!-- Observability -->
<micrometer-docs-generator.version>1.0.2</micrometer-docs-generator.version>
<micrometer-docs-generator.inputPath>${maven.multiModuleProjectDirectory}/</micrometer-docs-generator.inputPath>
<micrometer-docs-generator.inclusionPattern>.*</micrometer-docs-generator.inclusionPattern>
<micrometer-docs-generator.outputPath>${maven.multiModuleProjectDirectory}/docs/modules/ROOT/partials/</micrometer-docs-generator.outputPath>
</properties>
<dependencies>
<dependency>
@ -31,6 +38,12 @@ @@ -31,6 +38,12 @@
<profile>
<id>docs</id>
<build>
<resources>
<resource>
<directory>src/main/antora/resources/antora-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
@ -39,18 +52,44 @@ @@ -39,18 +52,44 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-observability-docs</id>
<phase>${generate-docs.phase}</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>io.micrometer.docs.DocsGeneratorCommand</mainClass>
<includePluginDependencies>true</includePluginDependencies>
<arguments>
<argument>${micrometer-docs-generator.inputPath}</argument>
<argument>${micrometer-docs-generator.inclusionPattern}</argument>
<argument>${micrometer-docs-generator.outputPath}</argument>
</arguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-docs-generator</artifactId>
<version>${micrometer-docs-generator.version}</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<groupId>io.spring.maven.antora</groupId>
<artifactId>antora-component-version-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<groupId>io.spring.maven.antora</groupId>
<artifactId>antora-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

20
docs/src/main/antora/resources/antora-resources/antora.yml

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
version: @antora-component.version@
prerelease: @antora-component.prerelease@
asciidoc:
attributes:
attribute-missing: 'warn'
chomp: 'all'
project-root: @maven.multiModuleProjectDirectory@
github-repo: @docs.main@
github-raw: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@
github-code: https://github.com/spring-cloud/@docs.main@/tree/@github-tag@
github-issues: https://github.com/spring-cloud/@docs.main@/issues/
github-wiki: https://github.com/spring-cloud/@docs.main@/wiki
spring-cloud-version: @project.version@
github-tag: @github-tag@
version-type: @version-type@
docs-url: https://docs.spring.io/@docs.main@/docs/@project.version@
raw-docs-url: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@
project-version: @project.version@
project-name: @docs.main@

25
docs/src/main/asciidoc/README.adoc

@ -1,15 +1,14 @@ @@ -1,15 +1,14 @@
image::https://circleci.com/gh/spring-cloud/spring-cloud-gateway/tree/master.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-gateway/tree/master"]
image::https://codecov.io/gh/spring-cloud/spring-cloud-gateway/branch/master/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-gateway/branch/master"]
image::https://api.codacy.com/project/badge/Grade/a6885a06921e4f72a0df0b7aabd6d118["Codacy code quality", link="https://www.codacy.com/app/spring-cloud/spring-cloud-gateway?utm_source=github.com&utm_medium=referral&utm_content=spring-cloud/spring-cloud-gateway&utm_campaign=Badge_Grade"]
image::https://github.com/spring-cloud/spring-cloud-gateway/workflows/Build/badge.svg?style=svg["Actions Status", link="https://github.com/spring-cloud/spring-cloud-gateway/actions"]
image::https://codecov.io/gh/spring-cloud/spring-cloud-gateway/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-gateway/branch/main"]
include::intro.adoc[]
== Features
[[features]]
= Features
* Java 8
* Spring Framework 5
* Spring Boot 2
* Java 17
* Spring Framework 6
* Spring Boot 3
* Dynamic routing
* Route matching built into Spring Handler Mapping
* Route matching on HTTP Request (Path, Method, Header, Host, etc...)
@ -18,10 +17,12 @@ include::intro.adoc[] @@ -18,10 +17,12 @@ include::intro.adoc[]
* API or configuration driven
* Supports Spring Cloud `DiscoveryClient` for configuring Routes
== Building
[[building]]
= Building
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/building-jdk8.adoc[]
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/modules/ROOT/partials/contributing.adoc[]
== Contributing
[[contributing]]
= Contributing
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing.adoc[]
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/contributing.adoc[]

147
docs/src/main/asciidoc/_configprops.adoc

@ -1,147 +0,0 @@ @@ -1,147 +0,0 @@
|===
|Name | Default | Description
|spring.cloud.gateway.default-filters | | List of filter definitions that are applied to every route.
|spring.cloud.gateway.discovery.locator.enabled | `false` | Flag that enables DiscoveryClient gateway integration.
|spring.cloud.gateway.discovery.locator.filters | |
|spring.cloud.gateway.discovery.locator.include-expression | `true` | SpEL expression that will evaluate whether to include a service in gateway integration or not, defaults to: true.
|spring.cloud.gateway.discovery.locator.lower-case-service-id | `false` | Option to lower case serviceId in predicates and filters, defaults to false. Useful with eureka when it automatically uppercases serviceId. so MYSERIVCE, would match /myservice/**
|spring.cloud.gateway.discovery.locator.predicates | |
|spring.cloud.gateway.discovery.locator.route-id-prefix | | The prefix for the routeId, defaults to discoveryClient.getClass().getSimpleName() + "_". Service Id will be appended to create the routeId.
|spring.cloud.gateway.discovery.locator.url-expression | `'lb://'+serviceId` | SpEL expression that create the uri for each route, defaults to: 'lb://'+serviceId.
|spring.cloud.gateway.enabled | `true` | Enables gateway functionality.
|spring.cloud.gateway.fail-on-route-definition-error | `true` | Option to fail on route definition errors, defaults to true. Otherwise, a warning is logged.
|spring.cloud.gateway.filter.add-request-header.enabled | `true` | Enables the add-request-header filter.
|spring.cloud.gateway.filter.add-request-parameter.enabled | `true` | Enables the add-request-parameter filter.
|spring.cloud.gateway.filter.add-response-header.enabled | `true` | Enables the add-response-header filter.
|spring.cloud.gateway.filter.circuit-breaker.enabled | `true` | Enables the circuit-breaker filter.
|spring.cloud.gateway.filter.dedupe-response-header.enabled | `true` | Enables the dedupe-response-header filter.
|spring.cloud.gateway.filter.fallback-headers.enabled | `true` | Enables the fallback-headers filter.
|spring.cloud.gateway.filter.hystrix.enabled | `true` | Enables the hystrix filter.
|spring.cloud.gateway.filter.map-request-header.enabled | `true` | Enables the map-request-header filter.
|spring.cloud.gateway.filter.modify-request-body.enabled | `true` | Enables the modify-request-body filter.
|spring.cloud.gateway.filter.modify-response-body.enabled | `true` | Enables the modify-response-body filter.
|spring.cloud.gateway.filter.prefix-path.enabled | `true` | Enables the prefix-path filter.
|spring.cloud.gateway.filter.preserve-host-header.enabled | `true` | Enables the preserve-host-header filter.
|spring.cloud.gateway.filter.redirect-to.enabled | `true` | Enables the redirect-to filter.
|spring.cloud.gateway.filter.remove-hop-by-hop.headers | |
|spring.cloud.gateway.filter.remove-hop-by-hop.order | |
|spring.cloud.gateway.filter.remove-request-header.enabled | `true` | Enables the remove-request-header filter.
|spring.cloud.gateway.filter.remove-request-parameter.enabled | `true` | Enables the remove-request-parameter filter.
|spring.cloud.gateway.filter.remove-response-header.enabled | `true` | Enables the remove-response-header filter.
|spring.cloud.gateway.filter.request-header-size.enabled | `true` | Enables the request-header-size filter.
|spring.cloud.gateway.filter.request-header-to-request-uri.enabled | `true` | Enables the request-header-to-request-uri filter.
|spring.cloud.gateway.filter.request-rate-limiter.deny-empty-key | `true` | Switch to deny requests if the Key Resolver returns an empty key, defaults to true.
|spring.cloud.gateway.filter.request-rate-limiter.empty-key-status-code | | HttpStatus to return when denyEmptyKey is true, defaults to FORBIDDEN.
|spring.cloud.gateway.filter.request-rate-limiter.enabled | `true` | Enables the request-rate-limiter filter.
|spring.cloud.gateway.filter.request-size.enabled | `true` | Enables the request-size filter.
|spring.cloud.gateway.filter.retry.enabled | `true` | Enables the retry filter.
|spring.cloud.gateway.filter.rewrite-location-response-header.enabled | `true` | Enables the rewrite-location-response-header filter.
|spring.cloud.gateway.filter.rewrite-location.enabled | `true` | Enables the rewrite-location filter.
|spring.cloud.gateway.filter.rewrite-path.enabled | `true` | Enables the rewrite-path filter.
|spring.cloud.gateway.filter.rewrite-response-header.enabled | `true` | Enables the rewrite-response-header filter.
|spring.cloud.gateway.filter.save-session.enabled | `true` | Enables the save-session filter.
|spring.cloud.gateway.filter.secure-headers.content-security-policy | `default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'` |
|spring.cloud.gateway.filter.secure-headers.content-type-options | `nosniff` |
|spring.cloud.gateway.filter.secure-headers.disable | |
|spring.cloud.gateway.filter.secure-headers.download-options | `noopen` |
|spring.cloud.gateway.filter.secure-headers.enabled | `true` | Enables the secure-headers filter.
|spring.cloud.gateway.filter.secure-headers.frame-options | `DENY` |
|spring.cloud.gateway.filter.secure-headers.permitted-cross-domain-policies | `none` |
|spring.cloud.gateway.filter.secure-headers.referrer-policy | `no-referrer` |
|spring.cloud.gateway.filter.secure-headers.strict-transport-security | `max-age=631138519` |
|spring.cloud.gateway.filter.secure-headers.xss-protection-header | `1 ; mode=block` |
|spring.cloud.gateway.filter.set-path.enabled | `true` | Enables the set-path filter.
|spring.cloud.gateway.filter.set-request-header.enabled | `true` | Enables the set-request-header filter.
|spring.cloud.gateway.filter.set-request-host-header.enabled | `true` | Enables the set-request-host-header filter.
|spring.cloud.gateway.filter.set-response-header.enabled | `true` | Enables the set-response-header filter.
|spring.cloud.gateway.filter.set-status.enabled | `true` | Enables the set-status filter.
|spring.cloud.gateway.filter.strip-prefix.enabled | `true` | Enables the strip-prefix filter.
|spring.cloud.gateway.forwarded.enabled | `true` | Enables the ForwardedHeadersFilter.
|spring.cloud.gateway.global-filter.adapt-cached-body.enabled | `true` | Enables the adapt-cached-body global filter.
|spring.cloud.gateway.global-filter.forward-path.enabled | `true` | Enables the forward-path global filter.
|spring.cloud.gateway.global-filter.forward-routing.enabled | `true` | Enables the forward-routing global filter.
|spring.cloud.gateway.global-filter.load-balancer-client.enabled | `true` | Enables the load-balancer-client global filter.
|spring.cloud.gateway.global-filter.netty-routing.enabled | `true` | Enables the netty-routing global filter.
|spring.cloud.gateway.global-filter.netty-write-response.enabled | `true` | Enables the netty-write-response global filter.
|spring.cloud.gateway.global-filter.reactive-load-balancer-client.enabled | `true` | Enables the reactive-load-balancer-client global filter.
|spring.cloud.gateway.global-filter.remove-cached-body.enabled | `true` | Enables the remove-cached-body global filter.
|spring.cloud.gateway.global-filter.route-to-request-url.enabled | `true` | Enables the route-to-request-url global filter.
|spring.cloud.gateway.global-filter.websocket-routing.enabled | `true` | Enables the websocket-routing global filter.
|spring.cloud.gateway.globalcors.add-to-simple-url-handler-mapping | `false` | If global CORS config should be added to the URL handler.
|spring.cloud.gateway.globalcors.cors-configurations | |
|spring.cloud.gateway.httpclient.compression | `false` | Enables compression for Netty HttpClient.
|spring.cloud.gateway.httpclient.connect-timeout | | The connect timeout in millis, the default is 45s.
|spring.cloud.gateway.httpclient.max-header-size | | The max response header size.
|spring.cloud.gateway.httpclient.max-initial-line-length | | The max initial line length.
|spring.cloud.gateway.httpclient.pool.acquire-timeout | | Only for type FIXED, the maximum time in millis to wait for acquiring.
|spring.cloud.gateway.httpclient.pool.eviction-interval | `0` | Perform regular eviction checks in the background at a specified interval. Disabled by default ({@link Duration#ZERO})
|spring.cloud.gateway.httpclient.pool.max-connections | | Only for type FIXED, the maximum number of connections before starting pending acquisition on existing ones.
|spring.cloud.gateway.httpclient.pool.max-idle-time | | Time in millis after which the channel will be closed. If NULL, there is no max idle time.
|spring.cloud.gateway.httpclient.pool.max-life-time | | Duration after which the channel will be closed. If NULL, there is no max life time.
|spring.cloud.gateway.httpclient.pool.metrics | `false` | Enables channel pools metrics to be collected and registered in Micrometer. Disabled by default.
|spring.cloud.gateway.httpclient.pool.name | `proxy` | The channel pool map name, defaults to proxy.
|spring.cloud.gateway.httpclient.pool.type | | Type of pool for HttpClient to use, defaults to ELASTIC.
|spring.cloud.gateway.httpclient.proxy.host | | Hostname for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.proxy.non-proxy-hosts-pattern | | Regular expression (Java) for a configured list of hosts. that should be reached directly, bypassing the proxy
|spring.cloud.gateway.httpclient.proxy.password | | Password for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.proxy.port | | Port for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.proxy.type | | proxyType for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.proxy.username | | Username for proxy configuration of Netty HttpClient.
|spring.cloud.gateway.httpclient.response-timeout | | The response timeout.
|spring.cloud.gateway.httpclient.ssl.close-notify-flush-timeout | `3000ms` | SSL close_notify flush timeout. Default to 3000 ms.
|spring.cloud.gateway.httpclient.ssl.close-notify-read-timeout | `0` | SSL close_notify read timeout. Default to 0 ms.
|spring.cloud.gateway.httpclient.ssl.default-configuration-type | | The default ssl configuration type. Defaults to TCP.
|spring.cloud.gateway.httpclient.ssl.handshake-timeout | `10000ms` | SSL handshake timeout. Default to 10000 ms
|spring.cloud.gateway.httpclient.ssl.key-password | | Key password, default is same as keyStorePassword.
|spring.cloud.gateway.httpclient.ssl.key-store | | Keystore path for Netty HttpClient.
|spring.cloud.gateway.httpclient.ssl.key-store-password | | Keystore password.
|spring.cloud.gateway.httpclient.ssl.key-store-provider | | Keystore provider for Netty HttpClient, optional field.
|spring.cloud.gateway.httpclient.ssl.key-store-type | `JKS` | Keystore type for Netty HttpClient, default is JKS.
|spring.cloud.gateway.httpclient.ssl.trusted-x509-certificates | | Trusted certificates for verifying the remote endpoint's certificate.
|spring.cloud.gateway.httpclient.ssl.use-insecure-trust-manager | `false` | Installs the netty InsecureTrustManagerFactory. This is insecure and not suitable for production.
|spring.cloud.gateway.httpclient.websocket.max-frame-payload-length | | Max frame payload length.
|spring.cloud.gateway.httpclient.websocket.proxy-ping | `true` | Proxy ping frames to downstream services, defaults to true.
|spring.cloud.gateway.httpclient.wiretap | `false` | Enables wiretap debugging for Netty HttpClient.
|spring.cloud.gateway.httpserver.wiretap | `false` | Enables wiretap debugging for Netty HttpServer.
|spring.cloud.gateway.loadbalancer.use404 | `false` |
|spring.cloud.gateway.metrics.enabled | `false` | Enables the collection of metrics data.
|spring.cloud.gateway.metrics.prefix | `spring.cloud.gateway` | The prefix of all metrics emitted by gateway.
|spring.cloud.gateway.metrics.tags | | Tags map that added to metrics.
|spring.cloud.gateway.metrics.tags.path.enabled | `false` | If the collection of metrics data is enabled, enables an extra metric data tag by path.
|spring.cloud.gateway.predicate.after.enabled | `true` | Enables the after predicate.
|spring.cloud.gateway.predicate.before.enabled | `true` | Enables the before predicate.
|spring.cloud.gateway.predicate.between.enabled | `true` | Enables the between predicate.
|spring.cloud.gateway.predicate.cloud-foundry-route-service.enabled | `true` | Enables the cloud-foundry-route-service predicate.
|spring.cloud.gateway.predicate.cookie.enabled | `true` | Enables the cookie predicate.
|spring.cloud.gateway.predicate.header.enabled | `true` | Enables the header predicate.
|spring.cloud.gateway.predicate.host.enabled | `true` | Enables the host predicate.
|spring.cloud.gateway.predicate.method.enabled | `true` | Enables the method predicate.
|spring.cloud.gateway.predicate.path.enabled | `true` | Enables the path predicate.
|spring.cloud.gateway.predicate.query.enabled | `true` | Enables the query predicate.
|spring.cloud.gateway.predicate.read-body.enabled | `true` | Enables the read-body predicate.
|spring.cloud.gateway.predicate.remote-addr.enabled | `true` | Enables the remote-addr predicate.
|spring.cloud.gateway.predicate.weight.enabled | `true` | Enables the weight predicate.
|spring.cloud.gateway.redis-rate-limiter.burst-capacity-header | `X-RateLimit-Burst-Capacity` | The name of the header that returns the burst capacity configuration.
|spring.cloud.gateway.redis-rate-limiter.config | |
|spring.cloud.gateway.redis-rate-limiter.include-headers | `true` | Whether or not to include headers containing rate limiter information, defaults to true.
|spring.cloud.gateway.redis-rate-limiter.remaining-header | `X-RateLimit-Remaining` | The name of the header that returns number of remaining requests during the current second.
|spring.cloud.gateway.redis-rate-limiter.replenish-rate-header | `X-RateLimit-Replenish-Rate` | The name of the header that returns the replenish rate configuration.
|spring.cloud.gateway.redis-rate-limiter.requested-tokens-header | `X-RateLimit-Requested-Tokens` | The name of the header that returns the requested tokens configuration.
|spring.cloud.gateway.routes | | List of Routes.
|spring.cloud.gateway.set-status.original-status-header-name | | The name of the header which contains http code of the proxied request.
|spring.cloud.gateway.streaming-media-types | |
|spring.cloud.gateway.x-forwarded.enabled | `true` | If the XForwardedHeadersFilter is enabled.
|spring.cloud.gateway.x-forwarded.for-append | `true` | If appending X-Forwarded-For as a list is enabled.
|spring.cloud.gateway.x-forwarded.for-enabled | `true` | If X-Forwarded-For is enabled.
|spring.cloud.gateway.x-forwarded.host-append | `true` | If appending X-Forwarded-Host as a list is enabled.
|spring.cloud.gateway.x-forwarded.host-enabled | `true` | If X-Forwarded-Host is enabled.
|spring.cloud.gateway.x-forwarded.order | `0` | The order of the XForwardedHeadersFilter.
|spring.cloud.gateway.x-forwarded.port-append | `true` | If appending X-Forwarded-Port as a list is enabled.
|spring.cloud.gateway.x-forwarded.port-enabled | `true` | If X-Forwarded-Port is enabled.
|spring.cloud.gateway.x-forwarded.prefix-append | `true` | If appending X-Forwarded-Prefix as a list is enabled.
|spring.cloud.gateway.x-forwarded.prefix-enabled | `true` | If X-Forwarded-Prefix is enabled.
|spring.cloud.gateway.x-forwarded.proto-append | `true` | If appending X-Forwarded-Proto as a list is enabled.
|spring.cloud.gateway.x-forwarded.proto-enabled | `true` | If X-Forwarded-Proto is enabled.
|===

1
docs/src/main/asciidoc/index.adoc

@ -1 +0,0 @@ @@ -1 +0,0 @@
spring-cloud-gateway.adoc

2813
docs/src/main/asciidoc/spring-cloud-gateway.adoc

File diff suppressed because it is too large Load Diff

51
pom.xml

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>4.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Spring Cloud Gateway</name>
@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>3.0.5</version>
<version>4.1.0-SNAPSHOT</version>
<relativePath/>
</parent>
<scm>
@ -51,12 +51,13 @@ @@ -51,12 +51,13 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bucket4j.version>8.6.0</bucket4j.version>
<blockhound.version>1.0.6.RELEASE</blockhound.version>
<java.version>1.8</java.version>
<junit-pioneer.version>1.0.0</junit-pioneer.version>
<spring-cloud-circuitbreaker.version>2.0.2</spring-cloud-circuitbreaker.version>
<spring-cloud-commons.version>3.0.6-SNAPSHOT</spring-cloud-commons.version>
<testcontainers.version>1.15.1</testcontainers.version>
<java.version>17</java.version>
<junit-pioneer.version>1.9.1</junit-pioneer.version>
<spring-cloud-circuitbreaker.version>3.1.0-SNAPSHOT</spring-cloud-circuitbreaker.version>
<spring-cloud-commons.version>4.1.0-SNAPSHOT</spring-cloud-commons.version>
<testcontainers.version>1.19.1</testcontainers.version>
</properties>
<dependencyManagement>
@ -78,7 +79,6 @@ @@ -78,7 +79,6 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-test-support</artifactId>
<scope>test</scope>
<version>${spring-cloud-commons.version}</version>
</dependency>
<dependency>
@ -98,6 +98,16 @@ @@ -98,6 +98,16 @@
<artifactId>spring-boot-devtools</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>com.bucket4j</groupId>
<artifactId>bucket4j-core</artifactId>
<version>${bucket4j.version}</version>
</dependency>
<dependency>
<groupId>com.bucket4j</groupId>
<artifactId>bucket4j-caffeine</artifactId>
<version>${bucket4j.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound</artifactId>
@ -128,7 +138,9 @@ @@ -128,7 +138,9 @@
<module>spring-cloud-gateway-mvc</module>
<module>spring-cloud-gateway-webflux</module>
<module>spring-cloud-gateway-server</module>
<module>spring-cloud-gateway-server-mvc</module>
<module>spring-cloud-starter-gateway</module>
<module>spring-cloud-starter-gateway-mvc</module>
<module>spring-cloud-gateway-sample</module>
<module>spring-cloud-gateway-integration-tests</module>
<module>docs</module>
@ -158,7 +170,7 @@ @@ -158,7 +170,7 @@
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
@ -169,7 +181,7 @@ @@ -169,7 +181,7 @@
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
@ -187,7 +199,7 @@ @@ -187,7 +199,7 @@
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
@ -198,7 +210,7 @@ @@ -198,7 +210,7 @@
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
@ -206,7 +218,7 @@ @@ -206,7 +218,7 @@
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release-local</url>
<url>https://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
@ -257,6 +269,19 @@ @@ -257,6 +269,19 @@
</plugins>
</build>
</profile>
<profile>
<id>withoutDockerTests</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>DockerRequired</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

22
spring-cloud-gateway-dependencies/pom.xml

@ -6,12 +6,12 @@ @@ -6,12 +6,12 @@
<parent>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>3.0.6-SNAPSHOT</version>
<version>4.1.0-SNAPSHOT</version>
<relativePath/>
</parent>
<artifactId>spring-cloud-gateway-dependencies</artifactId>
<version>3.0.7-SNAPSHOT</version>
<version>4.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>spring-cloud-gateway-dependencies</name>
@ -37,11 +37,21 @@ @@ -37,11 +37,21 @@
<artifactId>spring-cloud-gateway-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-server-mvc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway-mvc</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -52,7 +62,7 @@ @@ -52,7 +62,7 @@
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
@ -63,7 +73,7 @@ @@ -63,7 +73,7 @@
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
@ -81,7 +91,7 @@ @@ -81,7 +91,7 @@
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot-local</url>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
@ -92,7 +102,7 @@ @@ -92,7 +102,7 @@
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone-local</url>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>

131
spring-cloud-gateway-integration-tests/grpc/pom.xml

@ -0,0 +1,131 @@ @@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>grpc</artifactId>
<packaging>jar</packaging>
<name>Spring Cloud Gateway gRPC Integration Test</name>
<description>Spring Cloud Gateway gRPC Integration Test</description>
<properties>
<grpc.version>1.59.0</grpc.version>
</properties>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gateway-integration-tests</artifactId>
<version>4.1.0-SNAPSHOT</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-protobuf</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>annotations-api</artifactId>
<version>6.0.53</version>
<scope>provided</scope> <!-- not needed at runtime -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-test-support</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.1</version>
</extension>
</extensions>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.19.4:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.44.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save