use of org.springframework.http.HttpStatus in project pinpoint by naver.
the class ListenableFutureInterceptor method doInAfterTrace.
@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordServiceType(RestTemplateConstants.SERVICE_TYPE);
recorder.recordException(throwable);
recorder.recordApi(methodDescriptor);
if (args.length == 1 && args[0] instanceof AbstractClientHttpResponse) {
AbstractClientHttpResponse response = (AbstractClientHttpResponse) args[0];
try {
HttpStatus statusCode = response.getStatusCode();
if (statusCode != null) {
recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, statusCode.value());
}
this.responseHeaderRecorder.recordHeader(recorder, response);
} catch (IOException ioException) {
logger.warn("Failed to after process. {}", ioException.getMessage(), ioException);
}
}
}
use of org.springframework.http.HttpStatus in project spring-boot by spring-projects.
the class ManagementWebSecurityAutoConfigurationTests method usesMatchersBasedOffConfiguredActuatorBasePath.
@Test
void usesMatchersBasedOffConfiguredActuatorBasePath() {
this.contextRunner.withPropertyValues("management.endpoints.web.base-path=/").run((context) -> {
HttpStatus status = getResponseStatus(context, "/health");
assertThat(status).isEqualTo(HttpStatus.OK);
});
}
use of org.springframework.http.HttpStatus in project spring-boot by spring-projects.
the class ManagementWebSecurityAutoConfigurationTests method permitAllForHealth.
@Test
void permitAllForHealth() {
this.contextRunner.run((context) -> {
assertThat(context).hasBean(MANAGEMENT_SECURITY_FILTER_CHAIN_BEAN);
HttpStatus status = getResponseStatus(context, "/actuator/health");
assertThat(status).isEqualTo(HttpStatus.OK);
});
}
use of org.springframework.http.HttpStatus in project spring-boot by spring-projects.
the class WebMvcTags method uri.
/**
* Creates a {@code uri} tag based on the URI of the given {@code request}. Uses the
* {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern if
* available. Falling back to {@code REDIRECTION} for 3xx responses, {@code NOT_FOUND}
* for 404 responses, {@code root} for requests with no path info, and {@code UNKNOWN}
* for all other requests.
* @param request the request
* @param response the response
* @param ignoreTrailingSlash whether to ignore the trailing slash
* @return the uri tag derived from the request
*/
public static Tag uri(HttpServletRequest request, HttpServletResponse response, boolean ignoreTrailingSlash) {
if (request != null) {
String pattern = getMatchingPattern(request);
if (pattern != null) {
if (ignoreTrailingSlash && pattern.length() > 1) {
pattern = TRAILING_SLASH_PATTERN.matcher(pattern).replaceAll("");
}
if (pattern.isEmpty()) {
return URI_ROOT;
}
return Tag.of("uri", pattern);
}
if (response != null) {
HttpStatus status = extractStatus(response);
if (status != null) {
if (status.is3xxRedirection()) {
return URI_REDIRECTION;
}
if (status == HttpStatus.NOT_FOUND) {
return URI_NOT_FOUND;
}
}
}
String pathInfo = getPathInfo(request);
if (pathInfo.isEmpty()) {
return URI_ROOT;
}
}
return URI_UNKNOWN;
}
use of org.springframework.http.HttpStatus in project spring-boot by spring-projects.
the class MyControllerAdvice method getStatus.
private HttpStatus getStatus(HttpServletRequest request) {
Integer code = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
HttpStatus status = HttpStatus.resolve(code);
return (status != null) ? status : HttpStatus.INTERNAL_SERVER_ERROR;
}
Aggregations