Skip to content

Commit

Permalink
Added support for optional List<String> and UUID parameters in ht…
Browse files Browse the repository at this point in the history
…tp server controllers (#24)
  • Loading branch information
GoodforGod authored Dec 20, 2022
1 parent 4084e17 commit b872144
Show file tree
Hide file tree
Showing 32 changed files with 783 additions and 392 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

import ru.tinkoff.kora.http.client.common.annotation.HttpClient;
import ru.tinkoff.kora.http.common.HttpMethod;
import ru.tinkoff.kora.http.common.annotation.Header;
import ru.tinkoff.kora.http.common.annotation.HttpRoute;
import ru.tinkoff.kora.http.common.annotation.Query;

import javax.annotation.Nullable;
import java.time.LocalDate;
import java.util.List;

@HttpClient(configPath = "clientWithQueryParams")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import ru.tinkoff.kora.http.client.common.request.HttpClientRequest;
import ru.tinkoff.kora.http.client.common.response.HttpClientResponse;
import ru.tinkoff.kora.http.common.HttpMethod;
import ru.tinkoff.kora.http.common.annotation.*;
import ru.tinkoff.kora.http.common.annotation.HttpRoute;
import ru.tinkoff.kora.http.common.annotation.InterceptWith;
import ru.tinkoff.kora.http.common.annotation.Path;

import javax.annotation.Nullable;
import java.time.LocalDate;
import java.util.List;
import java.util.function.Function;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
import java.net.URI;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;

import static java.nio.charset.StandardCharsets.UTF_8;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package ru.tinkoff.kora.http.client.jdk;
;

import ru.tinkoff.kora.http.common.HttpHeaders;

import javax.annotation.Nonnull;
Expand All @@ -8,6 +8,8 @@
import java.util.List;
import java.util.Map;

;

public class JdkHttpClientHeaders implements HttpHeaders {
private final Map<String, List<String>> headers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ru.tinkoff.kora.http.client.symbol.processor.extension

import com.google.devtools.ksp.*
import com.google.devtools.ksp.KspExperimental
import com.google.devtools.ksp.getAnnotationsByType
import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.getConstructors
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.symbol.ClassKind
import com.google.devtools.ksp.symbol.KSClassDeclaration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import com.google.devtools.ksp.KspExperimental
import org.mockito.kotlin.any
import io.opentelemetry.api.trace.TracerProvider
import kotlinx.coroutines.runBlocking
import org.assertj.core.api.Assertions
Expand All @@ -15,6 +14,7 @@ import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.kotlin.any
import org.mockserver.integration.ClientAndServer
import org.mockserver.model.HttpRequest
import org.mockserver.model.HttpResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import ru.tinkoff.kora.http.client.common.interceptor.HttpClientInterceptor
import ru.tinkoff.kora.http.client.common.request.HttpClientRequest
import ru.tinkoff.kora.http.client.common.response.HttpClientResponse
import ru.tinkoff.kora.http.common.HttpMethod
import ru.tinkoff.kora.http.common.annotation.Header
import ru.tinkoff.kora.http.common.annotation.HttpRoute
import ru.tinkoff.kora.http.common.annotation.InterceptWith
import ru.tinkoff.kora.http.common.annotation.Path
import ru.tinkoff.kora.http.common.annotation.Query
import ru.tinkoff.kora.http.common.annotation.*
import java.util.function.Function

@HttpClient(telemetryTag = [GithubClient::class], httpClientTag = [GithubClient::class])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.Map;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;

class HttpHeadersImplTest {

@Test
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

import reactor.core.publisher.Mono;
import ru.tinkoff.kora.common.Mapping;
import ru.tinkoff.kora.http.common.HttpHeaders;
import ru.tinkoff.kora.http.common.HttpMethod;
import ru.tinkoff.kora.http.common.annotation.HttpRoute;
import ru.tinkoff.kora.http.server.common.HttpServerRequest;
import ru.tinkoff.kora.http.server.common.HttpServerResponseException;
import ru.tinkoff.kora.http.server.common.annotation.HttpController;
import ru.tinkoff.kora.http.server.common.handler.HttpServerRequestMapper;

import java.nio.charset.StandardCharsets;

@HttpController
public class MultipleParamsController {
public record Param1() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
public class TestControllerWithCustomReaders {

@HttpRoute(method = GET, path = "/test/{pathEntity}")
public HttpServerResponseEntity<String> test(@Query("queryEntity") List<ReadableEntity> queryList, @Path("pathEntity") ReadableEntity pathEntity, @Header("header-Entity") Optional<ReadableEntity> headerEntity) {
var resultList = new ArrayList<>(queryList);
public HttpServerResponseEntity<String> test(@Path("pathEntity") ReadableEntity pathEntity,
@Nullable @Query("queryEntity") List<ReadableEntity> queryList,
@Header("header-Entity") Optional<ReadableEntity> headerEntity) {
var resultList = queryList == null ? new ArrayList<ReadableEntity>() : new ArrayList<>(queryList);
resultList.add(pathEntity);

return new HttpServerResponseEntity<>(200, resultList.stream().map(ReadableEntity::string).collect(Collectors.joining(", ")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import ru.tinkoff.kora.http.server.common.HttpServerResponseEntity;
import ru.tinkoff.kora.http.server.common.annotation.HttpController;

import java.nio.ByteBuffer;

import static ru.tinkoff.kora.http.common.HttpMethod.GET;

@HttpController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
import ru.tinkoff.kora.common.readiness.ReadinessProbe;
import ru.tinkoff.kora.common.readiness.ReadinessProbeFailure;
import ru.tinkoff.kora.http.common.HttpHeaders;
import ru.tinkoff.kora.http.common.HttpResultCode;
import ru.tinkoff.kora.http.server.common.telemetry.HttpServerLogger;
import ru.tinkoff.kora.http.server.common.telemetry.PrivateApiMetrics;
import ru.tinkoff.kora.logging.common.MDC;

import javax.annotation.Nullable;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
Expand Down
Loading

0 comments on commit b872144

Please sign in to comment.