/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.actuate.endpoint.web;

import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExtension;

A WebEndpointResponse can be returned by an operation on a @EndpointWebExtension to provide additional, web-specific information such as the HTTP status code.
Author:Stephane Nicoll, Andy Wilkinson, Vedran Pavic
Type parameters:
  • <T> – the type of the response body
Since:2.0.0
/** * A {@code WebEndpointResponse} can be returned by an operation on a * {@link EndpointWebExtension @EndpointWebExtension} to provide additional, web-specific * information such as the HTTP status code. * * @param <T> the type of the response body * @author Stephane Nicoll * @author Andy Wilkinson * @author Vedran Pavic * @since 2.0.0 */
public final class WebEndpointResponse<T> {
200 OK.
/** * {@code 200 OK}. */
public static final int STATUS_OK = 200;
204 No Content.
/** * {@code 204 No Content}. */
public static final int STATUS_NO_CONTENT = 204;
400 Bad Request.
/** * {@code 400 Bad Request}. */
public static final int STATUS_BAD_REQUEST = 400;
404 Not Found.
/** * {@code 404 Not Found}. */
public static final int STATUS_NOT_FOUND = 404;
429 Too Many Requests.
/** * {@code 429 Too Many Requests}. */
public static final int STATUS_TOO_MANY_REQUESTS = 429;
500 Internal Server Error.
/** * {@code 500 Internal Server Error}. */
public static final int STATUS_INTERNAL_SERVER_ERROR = 500;
503 Service Unavailable.
/** * {@code 503 Service Unavailable}. */
public static final int STATUS_SERVICE_UNAVAILABLE = 503; private final T body; private final int status;
Creates a new WebEndpointResponse with no body and a 200 (OK) status.
/** * Creates a new {@code WebEndpointResponse} with no body and a 200 (OK) status. */
public WebEndpointResponse() { this(null); }
Creates a new WebEndpointResponse with no body and the given status.
Params:
  • status – the HTTP status
/** * Creates a new {@code WebEndpointResponse} with no body and the given * {@code status}. * @param status the HTTP status */
public WebEndpointResponse(int status) { this(null, status); }
Creates a new WebEndpointResponse with then given body and a 200 (OK) status.
Params:
  • body – the body
/** * Creates a new {@code WebEndpointResponse} with then given body and a 200 (OK) * status. * @param body the body */
public WebEndpointResponse(T body) { this(body, STATUS_OK); }
Creates a new WebEndpointResponse with then given body and status.
Params:
  • body – the body
  • status – the HTTP status
/** * Creates a new {@code WebEndpointResponse} with then given body and status. * @param body the body * @param status the HTTP status */
public WebEndpointResponse(T body, int status) { this.body = body; this.status = status; }
Returns the body for the response.
Returns:the body
/** * Returns the body for the response. * @return the body */
public T getBody() { return this.body; }
Returns the status for the response.
Returns:the status
/** * Returns the status for the response. * @return the status */
public int getStatus() { return this.status; } }