Package groovy.http
Annotation Interface HttpBuilderClient
Marks an interface as a declarative HTTP client. An implementation class
is generated at compile time via AST transform, using
HttpBuilder
for request execution.
Example:
@HttpBuilderClient('https://api.example.com') interface MyApi {@Get('/users/{id}') Map getUser(String id) } def api = MyApi.create() def user = api.getUser('123')
- Since:
- 6.0.0
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether requests are confined to the base URL.intConnection timeout in seconds.booleanWhether to follow HTTP redirects.intRequest timeout in seconds.
-
Element Details
-
value
String valueThe base URL for all requests.
-
-
-
connectTimeout
int connectTimeoutConnection timeout in seconds. Default 0 means no timeout.- Default:
- 0
-
requestTimeout
int requestTimeoutRequest timeout in seconds. Default 0 means no timeout.- Default:
- 0
-
followRedirects
boolean followRedirectsWhether to follow HTTP redirects. Default is false.- Default:
- false
-
confineToBaseUri
boolean confineToBaseUriWhether requests are confined to the base URL. Whentrue, a request whose resolved URI leaves the base URL's origin (scheme, host, or effective port) or its path prefix is rejected with aSecurityException. This covers a request template with an absolute path or..traversal, as well as an alternate base URL supplied to the generatedcreate(String)/create(Closure)factory that points at a different host. Default is false.- Default:
- false
-