Implementing Your Own Custom REST Connection Class

You can implement your own source code to make REST connections to the GenRocket Real-Time Server in any language.

Example Groovy REST Client

The following source code connects to the GenRocket Real-Time Server in Groovy over REST using port 8181.  

For the Groovy language, the HTTBuilder is a dependency for this code.


package com.genRocket


private static Map makeRequestAndRetrieveResponse(Map requestMap) {
    final String REST_URL = "http://localhost:8181/grRest"

    try {
      HTTPBuilder hTTPBuilder = new HTTPBuilder(REST_URL)
      Map jsonResp = [:]

      hTTPBuilder.request(Method.POST, ContentType.JSON) {
        body = requestMap

        response.success = { resp, json ->
          jsonResp = json as Map

        response.failure = { resp ->
          println "Request failed with status ${resp.status}"

      return jsonResp
    } catch (Exception ex) {
      return [success: false, errorMessage: ex.message]