Annotation Interface HttpExchange


@Target(TYPE) @Retention(RUNTIME) @Documented public @interface HttpExchange
Annotation that declares an HTTP service method as an HTTP endpoint defined through attributes of the annotation and method argument values.

The annotation may only be used at the type level — for example to specify a base URL path. At the method level, use one of the HTTP method specific, shortcut annotations, each of which is meta-annotated with HttpExchange:

Supported method arguments:

Method Argument Description Resolver
URI Dynamically set the URL for the request, overriding the annotation's url() attribute UrlArgumentResolver
HttpMethod Dynamically set the HTTP method for the request, overriding the annotation's method() attribute HttpMethodArgumentResolver
@RequestHeader Add a request header RequestHeaderArgumentResolver
@PathVariable Add a path variable for the URI template PathVariableArgumentResolver
@RequestBody Set the body of the request RequestBodyArgumentResolver
@RequestParam Add a request parameter, either form data if "Content-Type" is "application/x-www-form-urlencoded" or query params otherwise RequestParamArgumentResolver
@CookieValue Add a cookie CookieValueArgumentResolver
Since:
6.0
Author:
Rossen Stoyanchev
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The media types for the "Accept" header.
    The media type for the "Content-Type" header.
    The HTTP method to use.
    The URL for the request, either a full URL or a path only that is relative to a URL declared in a type-level @HttpExchange, and/or a globally configured base URL.
    This is an alias for url().
  • Element Details

    • value

      @AliasFor("url") String value
      This is an alias for url().
      Default:
      ""
    • url

      @AliasFor("value") String url
      The URL for the request, either a full URL or a path only that is relative to a URL declared in a type-level @HttpExchange, and/or a globally configured base URL.

      By default, this is empty.

      Default:
      ""
    • method

      String method
      The HTTP method to use.

      Supported at the type level as well as at the method level. When used at the type level, all method-level mappings inherit this value.

      By default, this is empty.

      Default:
      ""
    • contentType

      String contentType
      The media type for the "Content-Type" header.

      Supported at the type level as well as at the method level, in which case the method-level values override type-level values.

      By default, this is empty.

      Default:
      ""
    • accept

      String[] accept
      The media types for the "Accept" header.

      Supported at the type level as well as at the method level, in which case the method-level values override type-level values.

      By default, this is empty.

      Default:
      {}