use of es.moki.ratelimij.dropwizard.component.app.api.TrekResource in project ratelimitj by mokies.
the class RateLimitApplication method run.
@Override
public void run(Configuration configuration, Environment environment) {
environment.jersey().register(new LoginResource());
environment.jersey().register(new UserResource());
environment.jersey().register(new TrekResource());
environment.jersey().register(new AuthDynamicFeature(new OAuthCredentialAuthFilter.Builder<PrincipalImpl>().setAuthenticator(new TestOAuthAuthenticator()).setPrefix("Bearer").buildAuthFilter()));
environment.jersey().register(RolesAllowedDynamicFeature.class);
environment.jersey().register(new AuthValueFactoryProvider.Binder<>(PrincipalImpl.class));
// TODO move this cleanup into the tests
environment.lifecycle().manage(new Managed() {
@Override
public void start() {
}
@Override
public void stop() {
flushRedis();
}
private void flushRedis() {
try (StatefulRedisConnection<String, String> connection = redisClient.connect()) {
connection.sync().flushdb();
}
redisClient.shutdownAsync();
}
});
}
Aggregations