/** * Configures the execution of the provided closure "when" a successful response is received (code < 400). The `closure` will be called with * an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; * this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.success(){ * // executed when a successful response is received * } * } * ---- * * This method is the same as calling either the `when(Status.SUCCESS, Closure)` method. * * @param closure the closure to be executed */ default void success(Closure<?> closure) { success(new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status code (as a String) occurs in the response. The `closure` will be * called with an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value * of the request; this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when('404'){ * // executed when a 'not found' response is received * } * } * ---- * * @param code the response code to be caught * @param closure the closure to be executed */ default void when(String code, Closure<?> closure) { when(code, new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status code occurs in the response. The `closure` will be called with an instance * of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; this allows * the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when(404){ * // executed when a 'not found' response is received * } * } * ---- * * @param code the response code to be caught * @param closure the closure to be executed */ default void when(Integer code, Closure<?> closure) { when(code, new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status code occurs in the response. The `closure` will be called with an instance * of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; this allows * the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when(404){ * // executed when a 'not found' response is received * } * } * ---- * * @param code the response code to be caught * @param closure the closure to be executed */ default void when(Integer code, Closure<?> closure) { when(code, new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status code (as a String) occurs in the response. The `closure` will be * called with an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value * of the request; this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when('404'){ * // executed when a 'not found' response is received * } * } * ---- * * @param code the response code to be caught * @param closure the closure to be executed */ default void when(String code, Closure<?> closure) { when(code, new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" a successful response is received (code < 400). The `closure` will be called with * an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; * this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.success(){ * // executed when a successful response is received * } * } * ---- * * This method is the same as calling either the `when(Status.SUCCESS, Closure)` method. * * @param closure the closure to be executed */ default void success(Closure<?> closure) { success(new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status code (as a String) occurs in the response. The `closure` will be * called with an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value * of the request; this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when('404'){ * // executed when a 'not found' response is received * } * } * ---- * * @param code the response code to be caught * @param closure the closure to be executed */ default void when(String code, Closure<?> closure) { when(code, new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" a failure response is received (code >= 400). The `closure` will be called with * an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; * this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.failure { * // executed when a failure response is received * } * } * ---- * * This method is the same as calling either the `when(Status.FAILURE, Closure)` method. * * @param closure the closure to be executed */ default void failure(Closure<?> closure) { failure(new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" a failure response is received (code >= 400). The `closure` will be called with * an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; * this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.failure { * // executed when a failure response is received * } * } * ---- * * This method is the same as calling either the `when(Status.FAILURE, Closure)` method. * * @param closure the closure to be executed */ default void failure(Closure<?> closure) { failure(new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status occurs in the response. The `closure` will be called with an instance * of the response as a `FromServer` instance and the response body as an `Object` (if there is one). The value returned from the closure will be * used as the result value of the request; this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when(Status.SUCCESS){ * // executed when a successful response is received * } * } * ---- * * This method is the same as calling either the `success(Closure)` or `failure(Closure)` methods. Only one closure may be mapped to each * status. * * @param status the response {@link Status} enum * @param closure the closure to be executed */ default void when(Status status, Closure<?> closure) { when(status, new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status code occurs in the response. The `closure` will be called with an instance * of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; this allows * the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when(404){ * // executed when a 'not found' response is received * } * } * ---- * * @param code the response code to be caught * @param closure the closure to be executed */ default void when(Integer code, Closure<?> closure) { when(code, new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" a successful response is received (code < 400). The `closure` will be called with * an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; * this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.success(){ * // executed when a successful response is received * } * } * ---- * * This method is the same as calling either the `when(Status.SUCCESS, Closure)` method. * * @param closure the closure to be executed */ default void success(Closure<?> closure) { success(new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" a failure response is received (code >= 400). The `closure` will be called with * an instance of the response as a `FromServer` instance. The value returned from the closure will be used as the result value of the request; * this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.failure(){ * // executed when a failure response is received * } * } * ---- * * This method is the same as calling either the `when(Status.FAILURE, Closure)` method. * * @param closure the closure to be executed */ default void failure(Closure<?> closure) { failure(new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status occurs in the response. The `closure` will be called with an instance * of the response as a `FromServer` instance and the response body as an `Object` (if there is one). The value returned from the closure will be * used as the result value of the request; this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when(Status.SUCCESS){ * // executed when a successful response is received * } * } * ---- * * This method is the same as calling either the `success(Closure)` or `failure(Closure)` methods. Only one closure may be mapped to each * status. * * @param status the response {@link Status} enum * @param closure the closure to be executed */ default void when(Status status, Closure<?> closure) { when(status, new ClosureBiFunction<>(closure)); }
/** * Configures the execution of the provided closure "when" the given status occurs in the response. The `closure` will be called with an instance * of the response as a `FromServer` instance and the response body as an `Object` (if there is one). The value returned from the closure will be * used as the result value of the request; this allows the closure to modify the captured response. * * [source,groovy] * ---- * def http = HttpBuilder.configure { * request.uri = 'http://localhost:10101' * } * * http.get { * request.uri.path = '/foo' * response.when(Status.SUCCESS){ * // executed when a successful response is received * } * } * ---- * * This method is the same as calling either the `success(Closure)` or `failure(Closure)` methods. Only one closure may be mapped to each * status. * * @param status the response {@link Status} enum * @param closure the closure to be executed */ default void when(Status status, Closure<?> closure) { when(status, new ClosureBiFunction<>(closure)); }