Code Monkey home page Code Monkey logo

play-scala-rest-api-example's Introduction

Play REST API

Build Status

This is the example project for Making a REST API in Play.

Appendix

Running

You need to download and install sbt for this application to run.

Once you have sbt installed, the following at the command prompt will start up Play in development mode:

sbt run

Play will start up on the HTTP port at http://localhost:9000/. You don't need to deploy or reload anything -- changing any source code while the server is running will automatically recompile and hot-reload the application on the next HTTP request.

Usage

If you call the same URL from the command line, you’ll see JSON. Using httpie, we can execute the command:

http --verbose http://localhost:9000/v1/posts

and get back:

GET /v1/posts HTTP/1.1

Likewise, you can also send a POST directly as JSON:

http --verbose POST http://localhost:9000/v1/posts title="hello" body="world"

and get:

POST /v1/posts HTTP/1.1

Load Testing

The best way to see what Play can do is to run a load test. We've included Gatling in this test project for integrated load testing.

Start Play in production mode, by staging the application and running the play script:s

sbt stage
cd target/universal/stage
./bin/play-scala-rest-api-example -Dplay.http.secret.key=some-long-key-that-will-be-used-by-your-application

Then you'll start the Gatling load test up (it's already integrated into the project):

sbt gatling:test

For best results, start the gatling load test up on another machine so you do not have contending resources. You can edit the Gatling simulation, and change the numbers as appropriate.

Once the test completes, you'll see an HTML file containing the load test chart:

 ./rest-api/target/gatling/gatlingspec-1472579540405/index.html

That will contain your load test results.

play-scala-rest-api-example's People

Contributors

wsargent avatar marcospereira avatar gmethvin avatar octonato avatar corruptmemory avatar richdougherty avatar raboof avatar eed3si9n avatar justinpihony avatar sullis avatar

Watchers

James Cloos 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.