All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ftl.rest.server.method.$$RestControllerProducerMethodBodyTemplateftl Maven / Gradle / Ivy

There is a newer version: 0.11
Show newest version
<#-- --------------------------------------------- Static headers -------------------------------------------------- -->
<#if STATIC_HEADERS?has_content>
<#if STATIC_HEADERS?size == 1>
final HttpHeaders headers = HttpHeaders.of(<#list STATIC_HEADERS as e>"${e.key}", "${e.value}");
<#elseif STATIC_HEADERS?size <= 10>
final HttpHeaders headers = HttpHeaders.of(
    <#list STATIC_HEADERS as e>
        "${e.key}", "${e.value}"<#if e?has_next>,
    
);
<#else>
final HttpHeaders headers = HttpHeaders.of(
    <#list STATIC_HEADERS as e>
        java.util.Map.entry("${e.key}", "${e.value}")<#if e?has_next>,
    
);

<#else>
final HttpHeaders headers = HttpHeaders.of();

<#-- --------------------------------------------------------------------------------------------------------------- -->
<#if RETURN.future>
<#-- ------------------------------------ JSE CompletableFuture ---------------------------------------------- -->
<#if RETURN.optional>
return restController.${METHOD_NAME.simpleName}()
        .thenApply(optionalResponse -> optionalResponse
                .map(response -> buildResponse(response, ${STATUS_CODE}, headers))
                .orElse(${METHOD_NAME.uniqueJavaName}NotFoundResponse));
<#else>
return restController.${METHOD_NAME.simpleName}()
        .thenApply(response -> buildResponse(response, ${STATUS_CODE}, headers));

<#-- -------------------------------------- Spring Reactor Mono ---------------------------------------------- -->
<#elseif RETURN.mono>
return restController.${METHOD_NAME.simpleName}()
        .map(response -> buildResponse(response, ${STATUS_CODE}, headers))
        .defaultIfEmpty(${METHOD_NAME.uniqueJavaName}NotFoundResponse)
        .toFuture();
<#-- ---------------------------------------- RxJava Single -------------------------------------------------- -->
<#elseif RETURN.single>
return restController.${METHOD_NAME.simpleName}()
        .map(response -> buildResponse(response, ${STATUS_CODE}, headers))
        .toCompletionStage();
<#-- ----------------------------------------- RxJava Maybe -------------------------------------------------- -->
<#elseif RETURN.maybe>
return restController.${METHOD_NAME.simpleName}()
        .map(response -> buildResponse(response, ${STATUS_CODE}, headers))
        .defaultIfEmpty(${METHOD_NAME.uniqueJavaName}NotFoundResponse)
        .toCompletionStage();
<#-- --------------------------------------------------------------------------------------------------------------- -->
<#else>
//"The RxMicro framework does not know how to generate this method";
<#-- --------------------------------------------------------------------------------------------------------------- -->





© 2015 - 2024 Weber Informatics LLC | Privacy Policy