Skip to content

1.0 Controller Implementation

Anders Mikkelsen edited this page Dec 14, 2017 · 4 revisions

Controller implementation

A clean implementation expects two parameters, and accepts two optional parameters.

  • The vertx app configuration
    • For Redis backed etag storage, the configuration should have a parameter "redis_host", and an optional "redis_port". If not etags will not be stored remotely and will be checked for on the fly, before producing a response.
  • A Repository implementation that is typed to the class used for the RestControllerImpl.
  • An optional Function that reads the RoutingContext and returns a valid JsonObject based on the path, this is implemented by the client implementation. The default reads all path params.

The method postVerifyNotExists method should be overriden to set ids from the path if necessary. E.g. with a DynamoDB implemenation.

You can either extend the controller to do specific overrides like this example:

public class TestModelRESTController extends RestControllerImpl<TestModel> {
    public TestModelRESTController(JsonObject appConfig, Repository<TestModel> repository) {
        super(TestModel.class, appConfig, repository);
    }
}

or use the RestControllerImpl class directly for a standard REST controller (DynamoDBRepository as example):

Repository<TestModel> repository = new DynamoDBRepository<>(TestModel.class, config());
RestControllerImpl<TestModel> = new RestControllerImpl<TestModel>(TestModel.class, config(), repository);
Clone this wiki locally