Dropwizard Redirect Bundle

A simple bundle for DropWizard that allows for HTTP redirects.

Categories

Categories

DropWizard Container Microservices
GroupId

GroupId

com.bazaarvoice.dropwizard
ArtifactId

ArtifactId

dropwizard-redirect-bundle
Last Version

Last Version

0.4.0
Release Date

Release Date

Type

Type

jar
Description

Description

Dropwizard Redirect Bundle
A simple bundle for DropWizard that allows for HTTP redirects.
Source Code Management

Source Code Management

https://github.com/bazaarvoice/dropwizard-redirect-bundle

Download dropwizard-redirect-bundle

How to add to project

<!-- https://jarcasting.com/artifacts/com.bazaarvoice.dropwizard/dropwizard-redirect-bundle/ -->
<dependency>
    <groupId>com.bazaarvoice.dropwizard</groupId>
    <artifactId>dropwizard-redirect-bundle</artifactId>
    <version>0.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.bazaarvoice.dropwizard/dropwizard-redirect-bundle/
implementation 'com.bazaarvoice.dropwizard:dropwizard-redirect-bundle:0.4.0'
// https://jarcasting.com/artifacts/com.bazaarvoice.dropwizard/dropwizard-redirect-bundle/
implementation ("com.bazaarvoice.dropwizard:dropwizard-redirect-bundle:0.4.0")
'com.bazaarvoice.dropwizard:dropwizard-redirect-bundle:jar:0.4.0'
<dependency org="com.bazaarvoice.dropwizard" name="dropwizard-redirect-bundle" rev="0.4.0">
  <artifact name="dropwizard-redirect-bundle" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.bazaarvoice.dropwizard', module='dropwizard-redirect-bundle', version='0.4.0')
)
libraryDependencies += "com.bazaarvoice.dropwizard" % "dropwizard-redirect-bundle" % "0.4.0"
[com.bazaarvoice.dropwizard/dropwizard-redirect-bundle "0.4.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.google.guava : guava jar 17.0
io.dropwizard : dropwizard-core jar 0.7.1

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-core jar 1.9.5

Project Modules

There are no modules declared in this project.

NOTE: THIS PROJECT IS DEPRECATED. This projects is no longer maintained. It is deprecated for dropwizard-bundles maintained fork. Users of this project should update their project dependencies appropriately.

Getting Started

Just add this maven dependency:

<dependency>
  <groupId>com.bazaarvoice.dropwizard</groupId>
  <artifactId>dropwizard-redirect-bundle</artifactId>
  <version>0.4.0</version>
</dependency>
  • For Dropwizard 0.6.2: use version < 0.3.0
  • For Dropwizard 0.7.0: use version >= 0.3.0

To redirect one path to another path:

public class MyApplication extends Application<...> {
  // ...

  @Override
  public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.addBundle(new RedirectBundle(
      new PathRedirect("/old", "/new")
    ));
  }

  // ...
}

To redirect many paths at once:

public class MyApplication extends Application<...> {
  // ...

  @Override
  public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.addBundle(new RedirectBundle(
      new PathRedirect(ImmutableMap.<String, String>builder()
        .put("/old1", "/new1")
        .put("/old2", "/new2")
        .build())
    ));
  }

  // ...
}

To redirect non-HTTPS traffic to the HTTPS port:

public class MyApplication extends Application<...> {
  // ...

  @Override
  public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.addBundle(new RedirectBundle(
      new HttpsRedirect()
    ));
  }

  // ...
}

For more advanced users, there is also a regular expression based redirector that has access to the full URI. This operates in a similar fashion to the mod-rewrite module for Apache:

public class MyApplication extends Application<...> {
  // ...

  @Override
  public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.addBundle(new RedirectBundle(
      new UriRedirect("(.*)/welcome.html$", "$1/index.html")
    ));
  }

  // ...
}
com.bazaarvoice.dropwizard

Bazaarvoice

Versions

Version
0.4.0
0.3.0
0.2.0
0.1.1
0.1.0