public final class RestMethods extends Object
Constructor and Description |
---|
RestMethods(io.toro.martini.service.UrlRewriter urlRewriter) |
Modifier and Type | Method and Description |
---|---|
static Object |
jsonDelete(String url)
Execute a DELETE request against a web service.
|
static Object |
jsonDelete(String url,
Map<String,?> params)
Execute a DELETE request against a web service.
|
static Object |
jsonGet(String url)
Execute a GET request against a web service.
|
static Object |
jsonGet(String url,
groovy.lang.Closure closure)
Execute a GET request against a web service.
|
static Object |
jsonGet(String url,
Map<String,?> params)
Execute a GET request against a web service.
|
static Object |
jsonGet(String url,
Map<String,?> params,
groovy.lang.Closure closure)
Execute a GET request against a web service.
|
static Object |
jsonHead(String url)
Execute a HEAD request against a web service.
|
static Object |
jsonHead(String url,
Map<String,?> params)
Execute a HEAD request against a web service.
|
static Object |
jsonOptions(String url)
Execute an OPTIONS request against a web service.
|
static Object |
jsonOptions(String url,
Map<String,?> params)
Execute an OPTIONS request against a web service.
|
static Object |
jsonPatch(String url)
Execute a PATCH request against a web service.
|
static Object |
jsonPatch(String url,
Map<String,?> params)
Execute a PATCH request against a web service.
|
static Object |
jsonPost(String url)
Execute a POST request against a web service.
|
static Object |
jsonPost(String url,
groovy.lang.Closure closure)
Execute a POST request against a web service.
|
static Object |
jsonPost(String url,
Map<String,?> params)
Execute a POST request against a web service.
|
static Object |
jsonPost(String url,
Map<String,?> params,
groovy.lang.Closure closure)
Execute a POST request against a web service.
|
static Object |
jsonPut(String url)
Execute a POST request against a web service.
|
static Object |
jsonPut(String url,
Map<String,?> params)
Execute a POST request against a web service.
|
static Object |
request(String url,
String method,
groovyx.net.http.ContentType contentType,
groovy.lang.Closure configClosure)
Send a request, configured after the provided request data, to a RESTful web service.
|
static Object |
request(String url,
String method,
groovyx.net.http.ContentType contentType,
Map<String,?> params,
groovy.lang.Closure responseClosure)
Send a request, configured after the provided request data, to a RESTful web service.
|
static Object |
xmlDelete(String url)
Execute a DELETE request against a web service.
|
static Object |
xmlDelete(String url,
Map<String,?> params)
Execute a DELETE request against a web service.
|
static Object |
xmlGet(String url)
Execute a GET request against a web service.
|
static Object |
xmlGet(String url,
groovy.lang.Closure closure)
Execute a GET request against a web service.
|
static Object |
xmlGet(String url,
Map<String,?> params)
Execute a GET request against a web service.
|
static Object |
xmlGet(String url,
Map<String,?> params,
groovy.lang.Closure closure)
Execute a GET request against a web service.
|
static Object |
xmlHead(String url)
Execute a HEAD request against a web service.
|
static Object |
xmlHead(String url,
Map<String,?> params)
Execute a HEAD request against a web service.
|
static Object |
xmlOptions(String url)
Execute an OPTIONS request against a web service.
|
static Object |
xmlOptions(String url,
Map<String,?> params)
Execute an OPTIONS request against a web service.
|
static Object |
xmlPatch(String url)
Execute a PATCH request against a web service.
|
static Object |
xmlPatch(String url,
Map<String,?> params)
Execute a PATCH request against a web service.
|
static Object |
xmlPost(String url)
Execute a POST request against a web service.
|
static Object |
xmlPost(String url,
groovy.lang.Closure closure)
Execute a POST request against a web service.
|
static Object |
xmlPost(String url,
Map<String,?> params)
Execute a POST request against a web service.
|
static Object |
xmlPost(String url,
Map<String,?> params,
groovy.lang.Closure closure)
Execute a POST request against a web service.
|
static Object |
xmlPut(String url)
Execute a PUT request against a web service.
|
static Object |
xmlPut(String url,
Map<String,?> params)
Execute a PUT request against a web service.
|
@Autowired RestMethods(io.toro.martini.service.UrlRewriter urlRewriter)
public static Object request(String url, String method, groovyx.net.http.ContentType contentType, Map<String,?> params, groovy.lang.Closure responseClosure) throws IOException, URISyntaxException
uri
- the URL of the RESTful web servicemethod
- the type of HTTP method to usecontentType
- the content type of the request and responseparams
- a map of parameters
responseClosure
- closure to execute after the response has been receivedIllegalArgumentException
- if provided HTTP method is unknownIOException
URISyntaxException
public static Object request(String url, String method, groovyx.net.http.ContentType contentType, groovy.lang.Closure configClosure) throws IOException, URISyntaxException
configClosure
through
RequestConfigDelegate
.
Configurable properties include, but are not limited to:
url
- the URL of the RESTful web servicemethod
- the URL of the RESTful web servicecontentType
- the content type of the request and response;
either a ContentType
or valid content-type stringconfigClosure
- closure from which to configure request optionsIOException
URISyntaxException
public static Object jsonDelete(String url) throws IOException, URISyntaxException
Execute a DELETE request against a web service. JSON will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.jsonDelete().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object jsonDelete(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a DELETE request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.jsonDelete( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object jsonGet(String url, Map<String,?> params, groovy.lang.Closure closure) throws IOException, URISyntaxException
Execute a GET request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Additional processing for the response can be done through closure
.
Example usage:
def data = 'http://my.host/api/resource'.jsonGet( [ 'queryString': 'page=1&size=50' ] ) { response, reader -> { return reader } }
url
- the URL of the RESTful web serviceparams
- a map of parameters
closure
- closure to call after receiving the response, for further processingIOException
URISyntaxException
public static Object jsonGet(String url, groovy.lang.Closure closure) throws IOException, URISyntaxException
Execute a GET request against a web service.
JSON will be used as the request and response content type.
Additional processing for the response can be done through closure
.
Example usage:
def data = 'http://my.host/api/resource'.jsonGet() { response, reader -> { return reader } }
url
- the URL of the RESTful web serviceclosure
- closure to call after receiving the response, for further processingIOException
URISyntaxException
public static Object jsonGet(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a GET request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.jsonGet( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object jsonGet(String url) throws IOException, URISyntaxException
Execute a GET request against a web service. JSON will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.jsonGet().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object jsonHead(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a HEAD request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.jsonHead( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object jsonHead(String url) throws IOException, URISyntaxException
Execute a HEAD request against a web service. JSON will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.jsonHead().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object jsonOptions(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute an OPTIONS request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.jsonOptions( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object jsonOptions(String url) throws IOException, URISyntaxException
Execute an OPTIONS request against a web service. JSON will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.jsonOptions().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object jsonPatch(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a PATCH request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.jsonPatch( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object jsonPatch(String url) throws IOException, URISyntaxException
Execute a PATCH request against a web service. JSON will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.jsonPatch().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object jsonPost(String url, Map<String,?> params, groovy.lang.Closure closure) throws IOException, URISyntaxException
Execute a POST request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Additional processing for the response can be done through closure
.
Example usage:
def data = 'http://my.host/api/resource'.jsonPost( [ 'queryString': 'page=1&size=50' ] ) { response, reader -> { return reader } }
url
- the URL of the RESTful web serviceparams
- a map of parameters
closure
- closure to call after receiving the response, for further processingIOException
URISyntaxException
public static Object jsonPost(String url, groovy.lang.Closure closure) throws IOException, URISyntaxException
Execute a POST request against a web service.
JSON will be used as the request and response content type.
Additional processing for the response can be done through closure
.
Example usage:
def data = 'http://my.host/api/resource'.jsonPost() { response, reader -> { return reader } }
url
- the URL of the RESTful web serviceclosure
- closure to call after receiving the response, for further processingIOException
URISyntaxException
public static Object jsonPost(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a POST request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.jsonPost( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object jsonPost(String url) throws IOException, URISyntaxException
Execute a POST request against a web service. JSON will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.jsonPost().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object jsonPut(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a POST request against a web service.
JSON will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.jsonPut( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object jsonPut(String url) throws IOException, URISyntaxException
Execute a POST request against a web service. JSON will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.jsonPut().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object xmlDelete(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a DELETE request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.xmlDelete( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object xmlDelete(String url) throws IOException, URISyntaxException
Execute a DELETE request against a web service. XML will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.xmlDelete().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object xmlGet(String url, Map<String,?> params, groovy.lang.Closure closure) throws IOException, URISyntaxException
Execute a GET request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Additional processing for the response can be done through closure
.
Example usage:
def data = 'http://my.host/api/resource'.xmlGet( [ 'queryString': 'page=1&size=50' ] ) { response, reader -> { return reader } }
url
- the URL of the RESTful web serviceparams
- a map of parameters
closure
- closure to call after receiving the response, for further processingIOException
URISyntaxException
public static Object xmlGet(String url, groovy.lang.Closure closure) throws IOException, URISyntaxException
Execute a GET request against a web service.
XML will be used as the request and response content type.
Additional processing for the response can be done through closure
.
Example usage:
def data = 'http://my.host/api/resource'.xmlGet() { response, reader -> { return reader } }
url
- the URL of the RESTful web serviceclosure
- closure to call after receiving the response, for further processingIOException
URISyntaxException
public static Object xmlGet(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a GET request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.xmlGet( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object xmlGet(String url) throws IOException, URISyntaxException
Execute a GET request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.xmlGet().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object xmlHead(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a HEAD request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.xmlHead( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object xmlHead(String url) throws IOException, URISyntaxException
Execute a HEAD request against a web service. XML will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.xmlHead().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object xmlOptions(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute an OPTIONS request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.xmlOptions( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object xmlOptions(String url) throws IOException, URISyntaxException
Execute an OPTIONS request against a web service. XML will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.xmlOptions().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object xmlPatch(String url) throws IOException, URISyntaxException
Execute a PATCH request against a web service. XML will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.xmlPatch().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object xmlPatch(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a PATCH request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.xmlPatch( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object xmlPost(String url, Map<String,?> params, groovy.lang.Closure closure) throws IOException, URISyntaxException
Execute a POST request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Additional processing for the response can be done through closure
.
Example usage:
def data = 'http://my.host/api/resource'.xmlPost( [ 'queryString': 'page=1&size=50' ] ) { response, reader -> { return reader } }
url
- the URL of the RESTful web serviceparams
- a map of parameters
closure
- closure to call after receiving the response, for further processingIOException
URISyntaxException
public static Object xmlPost(String url, groovy.lang.Closure closure) throws IOException, URISyntaxException
Execute a POST request against a web service.
XML will be used as the request and response content type.
Additional processing for the response can be done through closure
.
Example usage:
def data = 'http://my.host/api/resource'.xmlPost() { response, reader -> { return reader } }
url
- the URL of the RESTful web serviceclosure
- closure to call after receiving the response, for further processingIOException
URISyntaxException
public static Object xmlPost(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a POST request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.xmlPost( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object xmlPost(String url) throws IOException, URISyntaxException
Execute a POST request against a web service. XML will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.xmlPost().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
public static Object xmlPut(String url, Map<String,?> params) throws IOException, URISyntaxException
Execute a PUT request against a web service.
XML will be used as the request and response content type.
Parameters for the to-be-executed request can be provided through params
.
Example usage:
def data = 'http://my.host/api/resource'.xmlPut( [ 'queryString': 'page=1&size=50' ] ).data
url
- the URL of the RESTful web serviceparams
- a map of parameters
IOException
URISyntaxException
public static Object xmlPut(String url) throws IOException, URISyntaxException
Execute a PUT request against a web service. XML will be used as the request and response content type.
Example usage:
def data = 'http://my.host/api/resource'.xmlPut().data
url
- the URL of the RESTful web serviceIOException
URISyntaxException
Copyright © 2020. All rights reserved.