Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update pom with dm's update bundle with conf
- Loading branch information
1 parent
79a04f7
commit 0c25bba
Showing
3 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,47 @@ | ||
# dropwizard-filter-bundle | ||
A small dropwizard bundle to filter resources based on mode supplied | ||
|
||
## What does it do? | ||
This bundle essentially restricts/allows the API based on mode supplied | ||
|
||
#### Modes available: | ||
- `READ_ONLY` | ||
- Allows only `GET` resources | ||
- `READ_WRITE` | ||
- Allows all resources | ||
|
||
#### Additional options: | ||
- 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 the `HttpMethod` and allows all requests even incase of `READ_ONLY` mode. | ||
|
||
|
||
## Usage | ||
Add the repository | ||
```xml | ||
<repository> | ||
<id>clojars</id> | ||
<name>Clojars repository</name> | ||
<url>https://clojars.org/repo</url> | ||
</repository> | ||
``` | ||
@Override | ||
public void initialize(final Bootstrap...) { | ||
bootstrap.addBundle(new ResourceFilterBundle() { | ||
public boolean withMode() { | ||
return FilterMode.READ_WRITE; | ||
} | ||
}); | ||
} | ||
|
||
Add the dependency | ||
```xml | ||
<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(); | ||
} | ||
}); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters