Package restx.http

Examples of restx.http.HttpStatus


                Matcher methodAndPathMatcher = Pattern.compile("(GET|POST|PUT|DELETE|HEAD|OPTIONS) (.+)").matcher(definition);

                if (methodAndPathMatcher.matches()) {
                    String then = checkInstanceOf("then", whenThen.get("then"), String.class).trim();
                    HttpStatus code = HttpStatus.OK;
                    int endLineIndex = then.indexOf("\n");
                    if (endLineIndex == -1) {
                        endLineIndex = then.length();
                    }
                    String firstLine = then.substring(0, endLineIndex);
                    Matcher respMatcher = Pattern.compile("^(\\d{3}).*$").matcher(firstLine);
                    if (respMatcher.matches()) {
                        code = HttpStatus.havingCode(Integer.parseInt(respMatcher.group(1)));
                        then = then.substring(endLineIndex).trim();
                    }

                    whens.add(whenHttpBuilder
                            .withMethod(methodAndPathMatcher.group(1))
                            .withPath(methodAndPathMatcher.group(2))
                            .withBody(body)
                            .withThen(new ThenHttpResponse(code.getCode(), then))
                            .build());
                } else {
                    throw new IllegalArgumentException("unrecognized 'when' format: it must begin with " +
                            "a HTTP declaration of the form 'VERB resource/path'\nEg: GET users/johndoe\n. Was: '" + ws + "'\n");
                }
View Full Code Here


                                annotation.methodElem.getSimpleName(), typeElem.getSimpleName()), typeElem);
                    continue;
                }

                SuccessStatus successStatusAnn = annotation.methodElem.getAnnotation(SuccessStatus.class);
                HttpStatus successStatus = successStatusAnn==null?HttpStatus.OK:successStatusAnn.value();

                Verbosity verbosity = annotation.methodElem.getAnnotation(Verbosity.class);
                RestxLogLevel logLevel = verbosity == null ? RestxLogLevel.DEFAULT : verbosity.value();

                ResourceGroup group = getResourceGroup(r, groups);
View Full Code Here

        this.uuidGenerator = uuidGenerator;
    }

    public <E> RestxError<E> on(Class<E> errorCode) {
        ErrorCode code = errorCode.getAnnotation(ErrorCode.class);
        HttpStatus errorStatus = code != null ? code.status() : HttpStatus.BAD_REQUEST;
        String error = code != null ? code.code() : errorCode.getSimpleName();
        String description = code != null ? code.description() : errorCode.getName();
        return new RestxError<>(uuidGenerator.doGenerate(), errorStatus, error, description);
    }
View Full Code Here

TOP

Related Classes of restx.http.HttpStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.