Skip to content

Commit 37c3b95

Browse files
authored
Merge pull request #1361 from 98001yash/docs/feign-client-builder
Add documentation for FeignClientBuilder
2 parents a058941 + 0386265 commit 37c3b95

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/modules/ROOT/pages/spring-cloud-openfeign.adoc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,46 @@ protected interface DemoFeignClient {
885885
}
886886
----
887887

888+
889+
=== FeignClientBuilder
890+
891+
`FeignClientBuilder` allows programmatic creation of Feign clients without using the `@FeignClient` annotation.
892+
893+
It builds clients in the same way as `@FeignClient`, but provides flexibility for dynamic use cases.
894+
895+
Unlike `@FeignClient`, which defines clients statically, `FeignClientBuilder` allows creating clients dynamically at runtime.
896+
897+
==== Basic Usage
898+
899+
[source,java,indent=0]
900+
----
901+
@Autowired
902+
private ApplicationContext applicationContext;
903+
904+
FeignClientBuilder builder = new FeignClientBuilder(applicationContext);
905+
906+
MyClient client = builder
907+
.forType(MyClient.class, "myClient")
908+
.url("http://localhost:8080")
909+
.build();
910+
----
911+
912+
==== Configuration Options
913+
914+
* `url(String url)` - Sets the target URL
915+
* `path(String path)` - Adds a base path
916+
* `contextId(String contextId)` - Unique identifier
917+
* `dismiss404(boolean)` - Ignore 404 errors
918+
* `inheritParentContext(boolean)` - Inherit parent config
919+
* `fallback(Class<? extends T>)` - Fallback class
920+
* `customize(FeignBuilderCustomizer)` - Customize Feign builder
921+
922+
==== When to Use
923+
924+
* Dynamic client creation
925+
* Runtime configuration
926+
* When `@FeignClient` is not sufficient
927+
888928
[[reactive-support]]
889929
=== Reactive Support
890930
As at the time of active development of Spring Cloud OpenFeign, the https://github.com/OpenFeign/feign[OpenFeign project] did not support reactive clients, such as https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/reactive/function/client/WebClient.html[Spring WebClient], such support could not be added to Spring Cloud OpenFeign either.

0 commit comments

Comments
 (0)