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

JavaPlayFramework.responseToResult.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{^controllerOnly}}
{{^returnType}}
{{#supportAsync}}
CompletableFuture result = CompletableFuture.supplyAsync(() -> {
        try {
{{/supportAsync}}
{{/returnType}}
{{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}}    {{/supportAsync}}{{/returnType}}{{^useInterfaces}}imp.{{/useInterfaces}}{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}}
{{#returnType}}
{{^isResponseFile}}
{{^returnTypeIsPrimitive}}
{{#useBeanValidation}}
{{^supportAsync}}
    if (configuration.getBoolean("useOutputBeanValidation")) {
        {{#isArray}}
        for ({{{returnType}}} curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
        {{/isArray}}
        {{#isMap}}
        for (Map.Entry entry : obj.entrySet()) {
            OpenAPIUtils.validate(entry.getValue());
        }
        {{/isMap}}
        {{^returnContainer}}
            OpenAPIUtils.validate(obj);
        {{/returnContainer}}
    }
{{/supportAsync}}
{{#supportAsync}}
    if (configuration.getBoolean("useOutputBeanValidation")) {
        {{#isArray}}
        for ({{{returnType}}} curItem : obj) {
            OpenAPIUtils.validate(curItem);
        }
        {{/isArray}}
        {{#isMap}}
        for (Map.Entry entry : obj.entrySet()) {
            OpenAPIUtils.validate(entry.getValue());
        }
        {{/isMap}}
        {{^returnContainer}}
        OpenAPIUtils.validate(obj);
        {{/returnContainer}}
    }
{{/supportAsync}}
{{/useBeanValidation}}
{{/returnTypeIsPrimitive}}
{{/isResponseFile}}
{{#supportAsync}}
    return obj;
});
{{/supportAsync}}
{{/returnType}}
{{#returnType}}
{{#supportAsync}}
return stage.thenApply(obj -> {
{{/supportAsync}}
{{^isResponseFile}}
{{#supportAsync}}    {{/supportAsync}}JsonNode result = mapper.valueToTree(obj);
{{#supportAsync}}    {{/supportAsync}}return ok(result);
{{/isResponseFile}}
{{#isResponseFile}}
{{#supportAsync}}    {{/supportAsync}}return ok(obj);
{{/isResponseFile}}
{{/returnType}}
{{^returnType}}
{{#supportAsync}}
        } catch (Exception e) {
            throw new CompletionException(e);
        }
        return ok();
    });
    return result;
{{/supportAsync}}
{{^supportAsync}}
return ok();
{{/supportAsync}}
{{/returnType}}
{{#returnType}}
{{#supportAsync}}
});
{{/supportAsync}}
{{/returnType}}
{{/controllerOnly}}
{{#controllerOnly}}
return ok();
{{/controllerOnly}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy