Below you'll find some useful REST related code snippets. REST-based services of JReflectServer all respond to GET or POST requests.
String value = request.getParameters().get("test"); |
Using raw request and response is a perfect method for writing webservices. Use the WebRequest.getHttpRequest() and WebResponse.getHttpResponse() method to access the low level http components. Please refer to the HttpCore tutorial for information.
If you define a custom response, you need to tell jReflect that you'd like to override the default response using WebResponse.setOverrideHttpReponse(true). Example:
HttpResponse httpResponse = response.getResponse(); |
Note: the code above is the implementation of the convenience method for a text response: WebResponse.text(...):
reponse.text(200, "Hello World!"); |