Package com.avoka.tm.http
package com.avoka.tm.http
Provides HTTP Client classes using underlying Apache HTTP Components library.
The example below performs REST request and returns a Path object.
import com.avoka.tm.http.* import com.avoka.tm.util.* Map params = [:] params.id = request.getParameter('customerId') params.account = request.getParameter('accountId') String username = svcDef.paramsMap.username String password = svcDef.paramsMap.password // execute GET request and return a HttpResponse object HttpResponse response = new GetRequest('https://service.mycorp.com/secure/rest/accounts/') .setParams(params) .setBasicAuth(username, password) .execute() if (response.isStatusOK()) { // get JSON object from the response Path path = response.getPathContent() ... } else if (response.isStatusNotFound()) { // object not found ... } else { throw new RuntimeException(response.statusLine) }
The example below performs POST request and converts the response into a Path document.
import com.avoka.tm.http.* import com.avoka.tm.util.* String message = '''{ "name":"John Doe", "email":"[email protected]", "age":42 }''' String username = svcDef.paramsMap.username String password = svcDef.paramsMap.password // execute POST request and return a HttpResponse object HttpResponse response = new PostRequest('https://service.mycorp.com/secure/rest/accounts/') .setMessage(message) .setBasicAuth(username, password) .execute() // check HttpResponse status code if (!response.isStatusOK()) { throw new RuntimeException(response.statusLine) } // get Path object from the response Path path = response.getPathContent() ...
-
ClassDescriptionProvides a DELETE Request class for performing simple HTTP request operations.Provides a GET Request class for performing simple HTTP request operations.Provides an abstract HttpRequest class enabling simpler use of the Apache HTTP Components library.Provides a multi-part FileParam.Provides a multi-part Param.Provides a HttpResponse value object class.Provides a PATCH Request class for performing simple HTTP request operations.Provides a POST Request class for performing simple HTTP request operations.Provides a PUT Request class for performing simple HTTP request operations.Provides a HTTP Request Builder class.