Skip to content

Latest commit

 

History

History
45 lines (37 loc) · 1.2 KB

File metadata and controls

45 lines (37 loc) · 1.2 KB

optionfactory-spring/upstream

HTTP Interface / RestClient / HttpComponents 5 SOAP and REST clients.

Maven

<dependency>
    <groupId>net.optionfactory.spring</groupId>
    <artifactId>upstream</artifactId>
</dependency>

Usage

1. Define the Client Interface

@Upstream("my-service")
@Upstream.Logging
public interface MyServiceClient {
    @GetExchange("/api/data")
    Map<String, String> fetchData(@RequestParam("id") String id);
}

2. Build the Client

@Bean
public MyServiceClient myServiceClient(JsonMapper mapper, ConfigurableApplicationContext ac) {
    return UpstreamBuilder.create(MyServiceClient.class)
            .requestFactoryHttpComponents(c -> {
                c.tlsSocketStrategy(HcSocketStrategies.system());
            })
            .json(mapper)
            .expressions(ac)
            .publisher(ac)
            .baseUri("https://api.example.com")
            .build();
}