dropwizard-jsonp-bundle

Simple bundle for Dropwizard that adds JSONP support for any resources

License

License

Categories

Categories

DropWizard Container Microservices JSON Data
GroupId

GroupId

com.github.alim-akbashev
ArtifactId

ArtifactId

dropwizard-jsonp-bundle
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

dropwizard-jsonp-bundle
Simple bundle for Dropwizard that adds JSONP support for any resources
Project URL

Project URL

https://github.com/alim-akbashev/dropwizard-jsonp-bundle
Source Code Management

Source Code Management

https://github.com/alim-akbashev/dropwizard-jsonp-bundle

Download dropwizard-jsonp-bundle

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
io.dropwizard : dropwizard-core jar 0.8.1

Project Modules

There are no modules declared in this project.

dropwizard-jsonp-bundle

Simple bundle for Dropwizard that adds JSONP support for any resources. Inspired by JsonWithPaddingInterceptor, but unlike last one it wraps response with callback() if callback arg is set in query string.

Maven

<dependency>
    <groupId>com.github.alim-akbashev</groupId>
    <artifactId>dropwizard-jsonp-bundle</artifactId>
    <version>0.0.1</version>
</dependency>

Usage

Initialize bundle:

public void initialize(final Bootstrap<AppConfiguration> bootstrap) {
    bootstrap.addBundle(new JsonPBundle());
}

Anotate resource using JSONP annotation:

@Path("/something")
public class SomeResource {

  @GET
  @JSONP(queryParam = "thecallback")
  public String get() {
    return "..."
  }

}

The queryParam is optional. Default value is callback.

Jquery Example

$.ajax({
    type: 'GET',
    url: "http://localhost/something",
    jsonp: "thecallback",
    dataType: "jsonp",
    success: function( response ) {
        console.log( response );
    }
});

Versions

Version
0.0.1