Browse Source

Polish Javadoc for @CrossOrigin

pull/811/head
Sam Brannen 11 years ago
parent
commit
1b5947bf88
  1. 58
      spring-web/src/main/java/org/springframework/web/bind/annotation/CrossOrigin.java

58
spring-web/src/main/java/org/springframework/web/bind/annotation/CrossOrigin.java

@ -23,59 +23,71 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/** /**
* Marks the annotated method as permitting cross origin requests. * Marks the annotated method or type as permitting cross origin requests.
* By default, all origins and headers are permitted. *
* <p>By default, all origins and headers are permitted.
* *
* @author Russell Allen * @author Russell Allen
* @author Sebastien Deleuze * @author Sebastien Deleuze
* @author Sam Brannen
* @since 4.2 * @since 4.2
*/ */
@Target({ElementType.METHOD, ElementType.TYPE}) @Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
public @interface CrossOrigin { public @interface CrossOrigin {
/** /**
* List of allowed origins. {@code "*"} means that all origins are allowed. These values * List of allowed origins.
* are placed in the {@code Access-Control-Allow-Origin} header of both the pre-flight * <p>These values are placed in the {@code Access-Control-Allow-Origin}
* and actual responses. Default value is <b>"*"</b>. * header of both the pre-flight response and the actual response.
* <p>Defaults to {@code "*"} which means that all origins are allowed.
*/ */
String[] origin() default {"*"}; String[] origin() default {"*"};
/** /**
* Indicates which request headers can be used during the actual request. {@code "*"} means * List of request headers that can be used during the actual request.
* that all headers asked by the client are allowed. This property controls the value of * <p>This property controls the value of the pre-flight response's
* pre-flight response's {@code Access-Control-Allow-Headers} header. Default value is * {@code Access-Control-Allow-Headers} header.
* <b>"*"</b>. * <p>Defaults to {@code "*"} which means that all headers requested
* by the client are allowed.
*/ */
String[] allowedHeaders() default {"*"}; String[] allowedHeaders() default {"*"};
/** /**
* List of response headers that the user-agent will allow the client to access. This property * List of response headers that the user-agent will allow the client to access.
* controls the value of actual response's {@code Access-Control-Expose-Headers} header. * <p>This property controls the value of actual response's
* {@code Access-Control-Expose-Headers} header.
* <p>Defaults to an empty array.
*/ */
String[] exposedHeaders() default {}; String[] exposedHeaders() default {};
/** /**
* The HTTP request methods to allow: GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE. * List of supported HTTP request methods.
* Methods specified here overrides {@code RequestMapping} ones. * <p>Methods specified here override those specified via {@code RequestMapping}.
* <p>Defaults to an empty array.
*/ */
RequestMethod[] method() default {}; RequestMethod[] method() default {};
/** /**
* Set to {@code "true"} if the the browser should include any cookies associated to the domain * Whether the browser should include any cookies associated with the
* of the request being annotated, or "false" if it should not. Empty string "" means undefined. * domain of the request being annotated.
* If true, the pre-flight response will include the header * <p>Set to {@code "false"} if such cookies should not included.
* {@code Access-Control-Allow-Credentials=true}. Default value is <b>"true"</b>. * <p>An empty string ({@code ""}) means <em>undefined</em>.
* <p>Defaults to {@code "true"} which means that the pre-flight
* response will include the header
* {@code Access-Control-Allow-Credentials=true}.
*/ */
String allowCredentials() default "true"; String allowCredentials() default "true";
/** /**
* Controls the cache duration for pre-flight responses. Setting this to a reasonable * The maximum age (in seconds) of the cache duration for pre-flight responses.
* value can reduce the number of pre-flight request/response interaction required by * <p>This property controls the value of the {@code Access-Control-Max-Age}
* the browser. This property controls the value of the {@code Access-Control-Max-Age header} * header in the pre-flight response.
* in the pre-flight response. Value set to -1 means undefined. Default value is * <p>A value of {@code -1} means <em>undefined</em>.
* <b>1800</b> seconds, or 30 minutes. * <p>Setting this to a reasonable value can reduce the number of pre-flight
* request/response interactions required by the browser.
* <p>Defaults to {@code 1800} seconds (i.e., 30 minutes).
*/ */
long maxAge() default 1800; long maxAge() default 1800;

Loading…
Cancel
Save