SpringMvcContract support parse params (#1016)
This commit is contained in:
@@ -45,7 +45,7 @@ public interface StoreClient {
|
||||
@GetMapping("/stores")
|
||||
Page<Store> getStores(Pageable pageable);
|
||||
|
||||
@PostMapping(value = "/stores/{storeId}", consumes = "application/json")
|
||||
@PostMapping(value = "/stores/{storeId}", consumes = "application/json", params = "mode=upsert")
|
||||
Store update(@PathVariable("storeId") Long storeId, Store store);
|
||||
|
||||
@DeleteMapping("/stores/{storeId:\\d+}")
|
||||
@@ -701,6 +701,36 @@ public interface DemoClient {
|
||||
|
||||
You can also disable the feature via property `spring.cloud.openfeign.cache.enabled=false`.
|
||||
|
||||
|
||||
[[spring-requestmapping-support]]
|
||||
=== Spring @RequestMapping Support
|
||||
|
||||
Spring Cloud OpenFeign provides support for the Spring `@RequestMapping` annotation and its derived annotations (such as `@GetMapping`, `@PostMapping`, and others) support.
|
||||
The attributes on the `@RequestMapping` annotation (including `value`, `method`, `params`, `headers`, `consumes`, and `produces`) are parsed by `SpringMvcContract` as the content of the request.
|
||||
|
||||
|
||||
Consider the following example:
|
||||
|
||||
Define an interface using the `params` attribute.
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
@FeignClient("demo")
|
||||
public interface DemoTemplate {
|
||||
|
||||
@PostMapping(value = "/stores/{storeId}", params = "mode=upsert")
|
||||
Store update(@PathVariable("storeId") Long storeId, Store store);
|
||||
}
|
||||
----
|
||||
|
||||
In the above example, the request url is resolved to `/stores/{storeId}?mode=upsert`. +
|
||||
The params attribute also supports the use of multiple `key=value` or only one `key`: +
|
||||
|
||||
- When `params = { "key1=v1", "key2=v2" }`, the request url is parsed as `/stores/{storeId}?key1=v1&key2=v2`.
|
||||
- When `params = "key"`, the request url is parsed as `/stores/{storeId}?key`.
|
||||
|
||||
|
||||
|
||||
[[feign-querymap-support]]
|
||||
=== Feign @QueryMap support
|
||||
|
||||
|
||||
Reference in New Issue
Block a user