Giter Club home page Giter Club logo

slim-play's Introduction

Slim Play App Build Status

Wanna build a really, really slim Play project?

This project demonstrates how you can easily build a non-blocking, threadsafe, and fast Play app without having to use the default routes file. The end-result should be familiar territory for people who are used to the simplicity of Sinatra/Bottle but want to take advantage of Scala's concurrent, type-safe and scalable nature.

Templates

In case you want to get up and running right away, use the following Slim-Play templates:

For Giter8: $ g8 lloydmeta/slim-play

How to run

  1. Git clone this project or use a template
  2. sbt run from the project's root directory
  3. Open a browser and hit:

How it was built

All I did was:

  1. Use sbt new to generate a new Play app ($ sbt new playframework/play-scala-seed.g8 --name=slim-play)
  2. Delete the auto-generated controller, public, and view directories (won't be using them)
  3. Create a AppLoader.scala file in the ./app directory, which holds an ApplicationLoader and the router, which is super simple:
val router = Router.from {
  case GET(p"/hello/$to") => Action {
    Ok(s"Hello $to")
  }
  /*
   Use Action.async to return a Future result (sqrt can be intense :P)
   Note the use of double(num) to bind only numbers (built-in :)
   */
  case GET(p"/sqrt/${double(num)}") => Action.async {
    Future {
      Ok(Math.sqrt(num).toString)
    }
  }
}
  1. Add play.application.loader=AppLoader to ./conf/application.conf so that Play knows to load our custom app (that contains our simple router)

More info

The following links may be useful for further understanding on what is happening here:

  1. Official Play docs on String Interpolating Routing DSL
  2. Official Play docs on Compile-time dependency injection

slim-play's People

Contributors

lloydmeta avatar wsargent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

slim-play's Issues

Update for 2.6.x

Now that Play 2.6.x is out, it'd be nice to have an update :-)

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.