From 7847fa443dc939ff729d98d17170058599acc57d Mon Sep 17 00:00:00 2001 From: Freeman Liu Date: Fri, 24 Nov 2023 22:55:21 +0800 Subject: [PATCH] ShadedHttpServiceProxyFactory add UriBuilderFactoryArgumentResolver --- .githooks/pre-commit | 2 +- .github/workflows/build.yml | 2 +- .../httpexchange/HttpExchangeProperties.java | 2 ++ .../shaded/ShadedHttpServiceProxyFactory.java | 18 +++++++++++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 5126835..4cd0659 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash ./gradlew spotlessApply > /dev/null diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12fe41e..782a4ec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ on: push: branches: - main - - 3.2.x + - 3.1.x jobs: build: runs-on: ubuntu-latest diff --git a/httpexchange-spring-boot-autoconfigure/src/main/java/io/github/danielliu1123/httpexchange/HttpExchangeProperties.java b/httpexchange-spring-boot-autoconfigure/src/main/java/io/github/danielliu1123/httpexchange/HttpExchangeProperties.java index 02ddfa8..e2c8f4a 100644 --- a/httpexchange-spring-boot-autoconfigure/src/main/java/io/github/danielliu1123/httpexchange/HttpExchangeProperties.java +++ b/httpexchange-spring-boot-autoconfigure/src/main/java/io/github/danielliu1123/httpexchange/HttpExchangeProperties.java @@ -91,6 +91,8 @@ public class HttpExchangeProperties implements InitializingBean { private Integer readTimeout; /** * Whether to check unused configuration, default {@code true}. + * + * @since 3.2.0 */ private boolean warnUnusedConfig = true; diff --git a/httpexchange-spring-boot-autoconfigure/src/main/java/io/github/danielliu1123/httpexchange/shaded/ShadedHttpServiceProxyFactory.java b/httpexchange-spring-boot-autoconfigure/src/main/java/io/github/danielliu1123/httpexchange/shaded/ShadedHttpServiceProxyFactory.java index a16069e..6d34fe6 100644 --- a/httpexchange-spring-boot-autoconfigure/src/main/java/io/github/danielliu1123/httpexchange/shaded/ShadedHttpServiceProxyFactory.java +++ b/httpexchange-spring-boot-autoconfigure/src/main/java/io/github/danielliu1123/httpexchange/shaded/ShadedHttpServiceProxyFactory.java @@ -53,6 +53,7 @@ import org.springframework.web.service.invoker.RequestHeaderArgumentResolver; import org.springframework.web.service.invoker.RequestParamArgumentResolver; import org.springframework.web.service.invoker.RequestPartArgumentResolver; +import org.springframework.web.service.invoker.UriBuilderFactoryArgumentResolver; import org.springframework.web.service.invoker.UrlArgumentResolver; import reactor.core.publisher.Mono; @@ -64,10 +65,10 @@ * {@link Builder Builder}. * * @author Rossen Stoyanchev - * @since 6.0 * @see org.springframework.web.client.support.RestClientAdapter * @see org.springframework.web.reactive.function.client.support.WebClientAdapter * @see org.springframework.web.client.support.RestTemplateAdapter + * @since 6.0 */ public final class ShadedHttpServiceProxyFactory { @@ -91,8 +92,9 @@ private ShadedHttpServiceProxyFactory( /** * Return a proxy that implements the given HTTP service interface to perform * HTTP requests and retrieve responses through an HTTP client. + * * @param serviceType the HTTP service to create a proxy for - * @param the HTTP service type + * @param the HTTP service type * @return the created proxy */ public S createClient(Class serviceType) { @@ -119,6 +121,7 @@ private ShadedHttpServiceMethod createHttpServiceMethod(Class serviceType /** * Return a builder that's initialized with the given client. + * * @since 6.1 */ public static Builder builderFor(HttpExchangeAdapter exchangeAdapter) { @@ -127,6 +130,7 @@ public static Builder builderFor(HttpExchangeAdapter exchangeAdapter) { /** * Return a builder that's initialized with the given client. + * * @deprecated in favor of {@link #builderFor(HttpExchangeAdapter)}; * to be removed in 6.2. */ @@ -148,7 +152,7 @@ public static Builder builder() { */ public static final class Builder { - // @Nullable + @Nullable private HttpExchangeAdapter exchangeAdapter; private final List customArgumentResolvers = new ArrayList<>(); @@ -163,6 +167,7 @@ private Builder() {} /** * Provide the HTTP client to perform requests through. + * * @param adapter a client adapted to {@link HttpExchangeAdapter} * @return this same builder instance * @since 6.1 @@ -174,6 +179,7 @@ public Builder exchangeAdapter(HttpExchangeAdapter adapter) { /** * Provide the HTTP client to perform requests through. + * * @param clientAdapter a client adapted to {@link HttpClientAdapter} * @return this same builder instance * @deprecated in favor of {@link #exchangeAdapter(HttpExchangeAdapter)}; @@ -188,6 +194,7 @@ public Builder clientAdapter(HttpClientAdapter clientAdapter) { /** * Register a custom argument resolver, invoked ahead of default resolvers. + * * @param resolver the resolver to add * @return this same builder instance */ @@ -200,6 +207,7 @@ public Builder customArgumentResolver(HttpServiceArgumentResolver resolver) { * Set the {@link ConversionService} to use where input values need to * be formatted as Strings. *

By default this is {@link DefaultFormattingConversionService}. + * * @return this same builder instance */ public Builder conversionService(ConversionService conversionService) { @@ -210,6 +218,7 @@ public Builder conversionService(ConversionService conversionService) { /** * Set the {@link StringValueResolver} to use for resolving placeholders * and expressions embedded in {@link HttpExchange#url()}. + * * @param embeddedValueResolver the resolver to use * @return this same builder instance */ @@ -222,6 +231,7 @@ public Builder embeddedValueResolver(StringValueResolver embeddedValueResolver) * Set the {@link ReactiveAdapterRegistry} to use to support different * asynchronous types for HTTP service method return values. *

By default this is {@link ReactiveAdapterRegistry#getSharedInstance()}. + * * @return this same builder instance * @deprecated in favor of setting the same directly on the {@link HttpExchangeAdapter} */ @@ -240,6 +250,7 @@ public Builder reactiveAdapterRegistry(ReactiveAdapterRegistry registry) { * connection and request timeout settings of the underlying HTTP client. * We recommend configuring timeout values directly on the underlying HTTP * client, which provides more control over such settings. + * * @param blockTimeout the timeout value * @return this same builder instance * @deprecated in favor of setting the same directly on the {@link HttpExchangeAdapter} @@ -285,6 +296,7 @@ private List initArgumentResolvers() { // Specific type resolvers.add(new UrlArgumentResolver()); + resolvers.add(new UriBuilderFactoryArgumentResolver()); resolvers.add(new HttpMethodArgumentResolver()); return resolvers;