Skip to content
Christian Metz edited this page Jul 13, 2013 · 2 revisions

Collection of response classes for TinyServer.

  • File response
  • HTML response
  • JSON response

Create your own

It's simple to create your own response class for a missing format.
Here is a template that helps you to get started.

  1. Create a new class that extends ResponseFormat.
  2. Add a constructor that defines your MIME type, by calling super(<MIME type>).
  3. Implement the abstract success method and override all other that are required.
    • use enum STATUS_CODE to get response codes and messages:
      STATUS_CODE.<type>.<method>STATUS_CODE.SUCCESS.getCode();
    • Available types: SUCCESS, FORBIDDEN, NOT_FOUND, ERROR
    • Available methods: getCode(), getHeader(), getDesc()
  4. Define the parameter type of the success() method, in a generic:
    class MyResponse extends ResponseFormat<Type>
Clone this wiki locally