@Override protected void processAnnotationOnMethod(MethodMetadata data, Annotation methodAnnotation, Method method) { Class<? extends Annotation> annotationType = methodAnnotation.annotationType(); HttpMethod http = annotationType.getAnnotation(HttpMethod.class); if (http != null) { checkState(data.template().method() == null, "Method %s contains multiple HTTP methods. Found: %s and %s", method.getName(), data.template() .method(), http.value()); data.template().method(http.value()); } else if (annotationType == Path.class) { String pathValue = emptyToNull(Path.class.cast(methodAnnotation).value()); checkState(pathValue != null, "Path.value() was empty on method %s", method.getName()); String methodAnnotationValue = Path.class.cast(methodAnnotation).value(); if (!methodAnnotationValue.startsWith("/") && !data.template().url().endsWith("/")) { methodAnnotationValue = "/" + methodAnnotationValue; } // jax-rs allows whitespace around the param name, as well as an optional regex. The contract should // strip these out appropriately. methodAnnotationValue = methodAnnotationValue.replaceAll("\\{\\s*(.+?)\\s*(:.+?)?\\}", "\\{$1\\}"); data.template().append(methodAnnotationValue); } else if (annotationType == Produces.class) { handleProducesAnnotation(data, (Produces) methodAnnotation, "method " + method.getName()); } else if (annotationType == Consumes.class) { handleConsumesAnnotation(data, (Consumes) methodAnnotation, "method " + method.getName()); } }
Request toRequest() { return new RequestTemplate() .method(request.method()) .append(getUri().toASCIIString()) .headers(request.headers()) .body(request.body(), request.charset()) .request(); }
pathValue = "/" + pathValue; data.template().append(pathValue);
pathValue = "/" + pathValue; data.template().append(pathValue);