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}}
{{#authMethods.0}}
{{#isOAuth}}
        if (!securityAPIUtils.isRequestTokenValid(request, "{{name}}")) {
            return {{#supportAsync}}CompletableFuture.supplyAsync(play.mvc.Results::unauthorized){{/supportAsync}}{{^supportAsync}}unauthorized(){{/supportAsync}};
        }

{{/isOAuth}}
{{/authMethods.0}}
{{^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}}

        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}}
        }

{{/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