Skip to content

Commit c00a6ba

Browse files
authored
Merge pull request mitre#128 from tomaytotomato/patch-1
Updated docs for Dropwizard integration
2 parents 109d212 + 2d80346 commit c00a6ba

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Ivy and other dependency managers can be used as well.
6363
Configuration
6464
-------------
6565

66+
## Servlet
67+
6668
Here's an example excerpt of a web.xml file to communicate to a Solr server:
6769

6870
<servlet>
@@ -106,11 +108,15 @@ them from the normal query parameters in case of a conflict.:
106108
<url-pattern>/mywebapp/cluster/*</url-pattern>
107109
</servlet-mapping>
108110

111+
## SpringMVC
112+
109113
If you are using **SpringMVC**, then an alternative is to use its
110114
[ServletWrappingController](http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/web/servlet/mvc/ServletWrappingController.html)
111115
so that you can configure this servlet via Spring, which is supremely flexible, instead of having to modify your web.xml. However, note that some
112116
customization may be needed to divide the URL at the proxied portion; see [Issue #15](https://github.com/mitre/HTTP-Proxy-Servlet/issues/15).
113117

118+
## Spring Boot
119+
114120
If you are using **Spring Boot**, then consider this basic configuration:
115121

116122
```java
@@ -142,3 +148,41 @@ proxy:
142148
servlet_url: /solr/*
143149
target_url: http://solrserver:8983/solr
144150
```
151+
152+
153+
## Dropwizard
154+
155+
Addition of Smiley's proxy to Dropwizard is very straightforward.
156+
157+
Add a new property in the Dropwizard app `.yml` file
158+
159+
```
160+
targetUri: http://foo.com/api
161+
```
162+
163+
Create a new configuration property
164+
165+
```
166+
@NotEmpty
167+
private String targetUri = "";
168+
169+
@JsonProperty("targetUri")
170+
public String getTargetUri() {
171+
return targetUri;
172+
}
173+
```
174+
175+
Then create register Smiley's proxy servlet with Jetty through the Dropwizard service's App `run()` method.
176+
177+
```
178+
@Override
179+
public void run(final ShepherdServiceConfiguration configuration,
180+
final Environment environment) {
181+
182+
183+
environment.getApplicationContext()
184+
.addServlet("org.mitre.dsmiley.httpproxy.ProxyServlet", "foo/*")
185+
.setInitParameter("targetUri", configuration.getTargetUri());
186+
```
187+
188+

0 commit comments

Comments
 (0)