/*
 * Copyright 2002-2012 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
 *
 *      http://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.web.bind.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.http.HttpStatus;

/**
 * Marks a method or exception class with the status code and reason that should be returned. The status code is applied
 * to the HTTP response when the handler method is invoked, or whenever said exception is thrown.
 *
 * @author Arjen Poutsma
 * @see org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver
 * @since 3.0
 */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ResponseStatus {

	/**
	 * The status code to use for the response.
	 *
	 * @see javax.servlet.http.HttpServletResponse#setStatus(int)
	 */
	HttpStatus value();

	/**
	 * The reason to be used for the response. <p>If this element is not set, it will default to the standard status
	 * message for the status code. Note that due to the use of {@code HttpServletResponse.sendError(int, String)},
	 * the response will be considered complete and should not be written to any further.
	 *
	 * @see javax.servlet.http.HttpServletResponse#sendError(int, String)
	 */
	String reason() default "";

}
