Java Code Examples for org.springframework.http.HttpStatus#name()

The following examples show how to use org.springframework.http.HttpStatus#name() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskanaErrorData.java    From taskana with Apache License 2.0 5 votes vote down vote up
TaskanaErrorData(HttpStatus stat, Exception ex, WebRequest req) {
  this.timestamp = new Date();
  this.status = stat.value();
  this.error = stat.name();
  this.exception = ex.getClass().getName();
  this.message = ex.getMessage();
  this.path = req.getDescription(false);
  if (this.path.startsWith("uri=")) {
    this.path = this.path.substring(4);
  }
}
 
Example 2
Source File: GatewayHttpTagsProvider.java    From spring-cloud-gateway with Apache License 2.0 5 votes vote down vote up
@Override
public Tags apply(ServerWebExchange exchange) {
	String outcome = "CUSTOM";
	String status = "CUSTOM";
	String httpStatusCodeStr = "NA";

	String httpMethod = exchange.getRequest().getMethodValue();

	// a non standard HTTPS status could be used. Let's be defensive here
	// it needs to be checked for first, otherwise the delegate response
	// who's status DIDN'T change, will be used
	if (exchange.getResponse() instanceof AbstractServerHttpResponse) {
		Integer statusInt = ((AbstractServerHttpResponse) exchange.getResponse())
				.getStatusCodeValue();
		if (statusInt != null) {
			status = String.valueOf(statusInt);
			httpStatusCodeStr = status;
			HttpStatus resolved = HttpStatus.resolve(statusInt);
			if (resolved != null) {
				// this is not a CUSTOM status, so use series here.
				outcome = resolved.series().name();
				status = resolved.name();
			}
		}
	}
	else {
		HttpStatus statusCode = exchange.getResponse().getStatusCode();
		if (statusCode != null) {
			httpStatusCodeStr = String.valueOf(statusCode.value());
			outcome = statusCode.series().name();
			status = statusCode.name();
		}
	}

	return Tags.of("outcome", outcome, "status", status, "httpStatusCode",
			httpStatusCodeStr, "httpMethod", httpMethod);
}
 
Example 3
Source File: HttpStatusCodeException.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Construct a new instance with an {@link HttpStatus}.
 * @param statusCode the status code
 */
protected HttpStatusCodeException(HttpStatus statusCode) {
	this(statusCode, statusCode.name(), null, null, null);
}
 
Example 4
Source File: HttpStatusCodeException.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Construct a new instance with an {@link HttpStatus}.
 * @param statusCode the status code
 */
protected HttpStatusCodeException(HttpStatus statusCode) {
	this(statusCode, statusCode.name(), null, null, null);
}
 
Example 5
Source File: HttpStatusCodeException.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Construct a new instance with an {@link HttpStatus}.
 * @param statusCode the status code
 */
protected HttpStatusCodeException(HttpStatus statusCode) {
	this(statusCode, statusCode.name(), null, null, null);
}
 
Example 6
Source File: HttpStatusCodeException.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Construct a new instance of {@code HttpStatusCodeException} based on an
 * {@link HttpStatus}.
 * @param statusCode the status code
 */
protected HttpStatusCodeException(HttpStatus statusCode) {
	this(statusCode, statusCode.name(), null, null, null);
}