GithubHelp home page GithubHelp logo

jersey-sample's Introduction

Compile / Build / Packaging using gradle

./gradle build
./gradlew war

The war file is compiled to build/libs/jersey.war

Deploying

Deploy the war by copying it into a web container such as Tomcat
cp build/libs/jersey.war $TOMCAT_HOME/webapps/
$TOMCAT_HOME/bin/startup.sh

Usage

When deployed into a local Tomcat instance, the index page is
http://localhost:8080

An example:
http://localhost:8080/rest/echo?m=hello

Documentation

Swagger Json:
http://localhost:8080/rest/api-docs

Fancy doc:
http://localhost:8080/api/
http://localhost:8080/api/#!/echo/post

There are still two places where a URL has to be hardcoded, to make it all work.
Like you can see, currently it all defaults to run as the root context.
Once you deploy the war however ... things change.
E.g. Once the jersey.war get deployed onto a app server, you'd access like this:

http://my.server.com:8080/jersey/index.html
http://my.server.com:8080/jersey/rest/echo?m=hello
http://my.server.com:8080/jersey/api/

For swagger still to work, edit the src/main/webapp/web.xml
In the servlet declaration for the JerseyJaxrsConfig edit the URL

<servlet>  
    <servlet-name>JerseyJaxrsConfig</servlet-name>  
    <servlet-class>io.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>  
    <init-param>  
        <param-name>api.version</param-name>  
        <param-value>1.0</param-value>  
    </init-param>  
    <init-param>  
        <param-name>swagger.api.basepath</param-name>  
        <param-value>http://localhost:8080/rest</param-value>  
    </init-param>  
    <load-on-startup>2</load-on-startup>  
</servlet> 

Like so: http://localhost:8080/jersey/rest

And in the src/main/webapp/api/index.html
Again, update the URL close to the top of the file:

<script type="text/javascript">  
$(function () {  
  var url = window.location.search.match(/url=([^&]+)/);  
  if (url && url.length > 1) {  
    url = decodeURIComponent(url[1]);  
  } else {  
    url = "/rest/swagger.yaml";  
  }

Like so: /jersey/rest/swagger.yaml

jersey-sample's People

Contributors

danielrobertson avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.