A small dropwizard bundle to filter resources based on mode supplied
This bundle essentially restricts/allows the API based on mode supplied
READ_ONLY
- Allows only
GET
resources
- Allows only
READ_WRITE
- Allows all resources
- There might cases where we end up having a read-only API with
POST
method, cases when we have a request body for filter params and so on. In these scenarios you can annotate specific resource with@ReadOnlyAPI
which discounts theHttpMethod
and allows all requests even incase ofREAD_ONLY
mode.
Add the repository
<repository>
<id>clojars</id>
<name>Clojars repository</name>
<url>https://clojars.org/repo</url>
</repository>
Add the dependency
<dependency>
<groupId>com.chaitanyachavali.dropwizard</groupId>
<artifactId>dropwizard-filters-bundle</artifactId>
<version>1.0.0</version>
</dependency>
Add the bundle to your application
@Override
public void initialize(Bootstrap bootstrap) {
bootstrap.addBundle(new ResourceFilterBundle<ApplicationConfiguration>() {
@Override
public FilterMode withMode(ApplicationConfiguration conf) {
return conf.getFilterMode();
}
});
}