Stub server plugin for quick front-end development

Proxy and Stub for Play2


play2-stub is a play framework plugin for routing requests to another server or return dummy data


GET    /index   contollers.YourController.index
GET    /*file


play2stub {
  routes: [
      "GET /author/~authorName/books" {
        template = "author-biology"
        data = "authors/:authorName.json"

Currently, play2-stub only supports Handlebars templates and depends on play2-handlebars .


  1. Sometimes engineers collaborate with front-end engineers or UX designers. While engineers are implementing eagerly, they want server responses to test their artifacts. Today since clients become richer and richer, they really needs clear responses for both html or ajax response.

  2. In micro service architecture, a server tends to access a lot of servers. Sometimes, it simply redirects and return the response and change a little and then return back to clients. We want minimize redunduncy to do such thngs.


  • Dynamic parameter passing
  • Implicit routing
  • Pluggable Processor ...
  • Pluggable Filter ...
  • Pluggable Template Resolver ...
  • Pluggable Param Injector ...
  • Pluggable Renderer ...

Getting Started

  1. Add a dependency in Build.scala or build.sbt

    "" %% "play2-stub" % "0.1.0"


"" %% "play2-stub" % "0.2-SNAPSHOT"

with the below to refer the Maven's snapshot reository. resolvers += "Maven Central Snapshots" at ""

  1. Add a line in conf/play.plugins. Usually, add Handlebars plugin declaration also currently.

  2. Add mappings to StubController routes in routes. Each http method needs a line.

    GET /*file POST /*file PUT /*file DELETE /*file

  3. Add routes in application.conf. The grammar is quite similar to that of Play's route. (But instead of ":", use "~" for path parameters currently).

    play2stub { routes: [ { "GET /author/~authorName/books" { template = "author-biology" data = "authors/:authorName.json" } } ] }

  4. Then put template files or/and json files and run your application.

  5. See src/test/play2-sample1-stub for more routing samples.