Giter Site home page Giter Site logo

airlift-example's Introduction

This is a simple usage of the airlift.io platform meant to be used as an example of various best practices.

Simple usage of:

  • Dependency injection (via guice)
  • Configuration
  • RESTful JSON calls
  • Logging
  • Unit tests
  • Other things, by request!

The project was generated using the maven archetype generator:

mvn archetype:generate -U -B \
  -DarchetypeGroupId=io.airlift \
  -DarchetypeArtifactId=skeleton-server-archetype \
  -DarchetypeVersion=0.84 \
  -DgroupId=io.airlift \
  -DartifactId=service-monitor \
  -Dpackage=com.tellapart.monitoring

Package

This project can be packaged with maven:

mvn package

Run

After packaging, to run the example server, do the following from the project root directory:

cd target
tar xvzf airlift-example-1.0-SNAPSHOT.tar.gz
cd airlift-example-1.0-SNAPSHOT
ln -s ../../etc
touch etc/jvm.config
bin/launcher run

Test

In a separate terminal window, the following commands should run as follows:

Exercise the HelloResource

$ curl localhost:8080/v1/hello/david
{"name":"david"}
$ curl localhost:8080/v1/hello/david?pretty
{
   "name":"david"
}

Exercise the ConfigurableHelloResource

$ curl localhost:8080/v2/hello/david
{"salutations":"Hola, david"}

Exercise the JsonConsumingResource

curl localhost:8080/v1/helloJson -H'Content-Type: application/json' -d '{ "firstName" : "David", "lastName" : "Hagar" }'
{"greeting":"Hello David Hagar"}

Illustrate unbound URI

$ curl localhost:8080/v1.1/hello/david
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /v1.1/hello/david. Reason:
<pre>    Not Found</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>

airlift-example's People

Contributors

davidhagar avatar

Watchers

 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.