All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fi.linuxbox.upcloud.http.spi.META.groovy Maven / Gradle / Ivy

There is a newer version: 0.0.7
Show newest version
package fi.linuxbox.upcloud.http.spi
/**
 * Meta information about a resource.
 *
 * 

* This is basically the head of the HTTP message: the status code, the reason phrase, and the headers. In the * application level callbacks, a reference to an instance of this class can be found in every resource. For example, * given the following odd response from the server: *

* *
 *     HTTP1.1 200 OK
 *     Content-Type: application/json; charset=UTF-8
 *
 *     {
 *         "error": {
 *             "error_code": "BAD_REQUEST",
 *             "error_message": "The value of foo cannot be bar"
 *         }
 *     }
 * 
* * The application callback will be called with an instance of {@link Resource} as the first parameter: * *
 *     { response ->
 *       assert response instanceof fi.linuxbox.upcloud.core.Resource
 *       assert response.META.status == 200
 *       assert response.META.message == "OK"
 *       assert response.error instanceof fi.linuxbox.upcloud.resource.Error
 *       assert response.error.errorCode == "BAD_REQUEST"
 *       assert response.error.errorMessage == "The value of foo cannot be bar"
 *     }
 * 
*/ class META { /** * The HTTP status code. * *

* This is never null. *

*/ final Integer status /** * The HTTP reason phrase. * *

* This may be null. *

*/ final String message /** * The HTTP headers. */ final Headers headers /** * Designated constructor. * * @param status The HTTP status code. This must not be null. * @param message The HTTP status phrase. May be null. * @param headers The HTTP headers. */ META(int status, String message, Headers headers) { this.status = status this.message = message this.headers = headers } /** * Constructor that sets the message to null. * * @param status The HTTP status code. This must not be null. * @param headers The HTTP headers. */ META(int status, Headers headers) { this(status, null, headers) } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy