Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
linenumberstrue
{  
	"name":"Passengers",
	"info": {  
	  	"rating":5,
	    "releaseDate":null
	}
}


Custom Formatting with API Plugin

The following interface can be implemented to customize the response.


Code Block
public interface ResponseFormatter {

    /**
     * Format final response generated by API
     *
     * @param response
     * @return
     */
    public String format(Response response);
}


Code Block
public class AcmeFormatter implements ResponseFormatter {
    public String format(Response response){
      JSONObject responseJson = (JSONObject) response.getPayload();
      //modify the responseJson
	  return responseJson.toString();
    }
}