diff --git a/multi/multi_spring-cloud-feign.html b/multi/multi_spring-cloud-feign.html index 8ec1ce98..5289f5a4 100644 --- a/multi/multi_spring-cloud-feign.html +++ b/multi/multi_spring-cloud-feign.html @@ -196,4 +196,18 @@ stripped). The proxy uses Ribbon to locate an instance to forward to via discovery, and all requests are executed in a <<hystrix-fallbacks-for-routes, hystrix command>>, so failures will show up in Hystrix metrics, and once the circuit is open -the proxy will not try to contact the service. \ No newline at end of file +the proxy will not try to contact the service.

1.10 Feign @QueryMap support

The OpenFeign @QueryMap annotation provides support for POJOs to be used as +GET parameter maps. Unfortunately, the default OpenFeign QueryMap annotation is +incompatible with Spring because it lacks a value property.

Spring Cloud OpenFeign provides an equivalent @SpringQueryMap annotation, which +is used to annotate a POJO or Map parameter as a query parameter map.

For example, the Params class defines parameters param1 and param2:

// Params.java
+public class Params {
+    private String param1;
+    private String param2;
+
+    // [Getters and setters omitted for brevity]
+}

The following feign client uses the Params class by using the @SpringQueryMap annotation:

@FeignClient("demo")
+public class DemoTemplate {
+
+    @GetMapping(path = "/demo")
+    String demoEndpoint(@SpringQueryMap Params params);
+}
\ No newline at end of file diff --git a/multi/multi_spring-cloud-openfeign.html b/multi/multi_spring-cloud-openfeign.html index ce08a84c..0bf00c7e 100644 --- a/multi/multi_spring-cloud-openfeign.html +++ b/multi/multi_spring-cloud-openfeign.html @@ -1,3 +1,3 @@ - Spring Cloud OpenFeign

Spring Cloud OpenFeign


Table of Contents

1. Declarative REST Client: Feign
1.1. How to Include Feign
1.2. Overriding Feign Defaults
1.3. Creating Feign Clients Manually
1.4. Feign Hystrix Support
1.5. Feign Hystrix Fallbacks
1.6. Feign and @Primary
1.7. Feign Inheritance Support
1.8. Feign request/response compression
1.9. Feign logging
\ No newline at end of file + Spring Cloud OpenFeign

Spring Cloud OpenFeign


Table of Contents

1. Declarative REST Client: Feign
1.1. How to Include Feign
1.2. Overriding Feign Defaults
1.3. Creating Feign Clients Manually
1.4. Feign Hystrix Support
1.5. Feign Hystrix Fallbacks
1.6. Feign and @Primary
1.7. Feign Inheritance Support
1.8. Feign request/response compression
1.9. Feign logging
1.10. Feign @QueryMap support
\ No newline at end of file diff --git a/single/spring-cloud-openfeign.html b/single/spring-cloud-openfeign.html index abe064d5..1236cbaf 100644 --- a/single/spring-cloud-openfeign.html +++ b/single/spring-cloud-openfeign.html @@ -1,6 +1,6 @@ - Spring Cloud OpenFeign

Spring Cloud OpenFeign


Table of Contents

1. Declarative REST Client: Feign
1.1. How to Include Feign
1.2. Overriding Feign Defaults
1.3. Creating Feign Clients Manually
1.4. Feign Hystrix Support
1.5. Feign Hystrix Fallbacks
1.6. Feign and @Primary
1.7. Feign Inheritance Support
1.8. Feign request/response compression
1.9. Feign logging

2.1.0.BUILD-SNAPSHOT

This project provides OpenFeign integrations for Spring Boot apps through autoconfiguration + Spring Cloud OpenFeign

Spring Cloud OpenFeign


2.1.0.BUILD-SNAPSHOT

This project provides OpenFeign integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms.

1. Declarative REST Client: Feign

Feign is a declarative web service client. It makes writing web service clients easier. To use Feign create an interface and annotate it. It has pluggable annotation support including Feign annotations and JAX-RS annotations. Feign also supports pluggable encoders and decoders. Spring Cloud adds support for Spring MVC annotations and for using the same HttpMessageConverters used by default in Spring Web. Spring Cloud integrates Ribbon and Eureka to provide a load balanced http client when using Feign.

1.1 How to Include Feign

To include Feign in your project use the starter with group org.springframework.cloud and artifact id spring-cloud-starter-openfeign. See the Spring Cloud Project page for details on setting up your build system with the current Spring Cloud Release Train.

Example spring boot app

@SpringBootApplication
@@ -197,4 +197,18 @@ stripped). The proxy uses Ribbon to locate an instance to forward to
 via discovery, and all requests are executed in a
 <<hystrix-fallbacks-for-routes, hystrix command>>, so
 failures will show up in Hystrix metrics, and once the circuit is open
-the proxy will not try to contact the service.
\ No newline at end of file +the proxy will not try to contact the service.

1.10 Feign @QueryMap support

The OpenFeign @QueryMap annotation provides support for POJOs to be used as +GET parameter maps. Unfortunately, the default OpenFeign QueryMap annotation is +incompatible with Spring because it lacks a value property.

Spring Cloud OpenFeign provides an equivalent @SpringQueryMap annotation, which +is used to annotate a POJO or Map parameter as a query parameter map.

For example, the Params class defines parameters param1 and param2:

// Params.java
+public class Params {
+    private String param1;
+    private String param2;
+
+    // [Getters and setters omitted for brevity]
+}

The following feign client uses the Params class by using the @SpringQueryMap annotation:

@FeignClient("demo")
+public class DemoTemplate {
+
+    @GetMapping(path = "/demo")
+    String demoEndpoint(@SpringQueryMap Params params);
+}
\ No newline at end of file diff --git a/spring-cloud-openfeign.xml b/spring-cloud-openfeign.xml index 09c24920..7391b64f 100644 --- a/spring-cloud-openfeign.xml +++ b/spring-cloud-openfeign.xml @@ -391,5 +391,28 @@ via discovery, and all requests are executed in a failures will show up in Hystrix metrics, and once the circuit is open the proxy will not try to contact the service. +
+Feign <literal>@QueryMap</literal> support +The OpenFeign @QueryMap annotation provides support for POJOs to be used as +GET parameter maps. Unfortunately, the default OpenFeign QueryMap annotation is +incompatible with Spring because it lacks a value property. +Spring Cloud OpenFeign provides an equivalent @SpringQueryMap annotation, which +is used to annotate a POJO or Map parameter as a query parameter map. +For example, the Params class defines parameters param1 and param2: +// Params.java +public class Params { + private String param1; + private String param2; + + // [Getters and setters omitted for brevity] +} +The following feign client uses the Params class by using the @SpringQueryMap annotation: +@FeignClient("demo") +public class DemoTemplate { + + @GetMapping(path = "/demo") + String demoEndpoint(@SpringQueryMap Params params); +} +
\ No newline at end of file