Skip to content

Instantly share code, notes, and snippets.

@mkotsbak
Last active May 20, 2016 18:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mkotsbak/122940aa003db9708093 to your computer and use it in GitHub Desktop.
Save mkotsbak/122940aa003db9708093 to your computer and use it in GitHub Desktop.
In Application.scala:
object MyServer extends AutowirePlayServer[Api] {
override def routes(target: Api) = route[Api](target)
override def createImpl(autowireContext: AutowireContext): Api = new ServerImpl(autowireContext)
}
object Application extends Controller {
def api = PlayAutowire.api(MyServer)_
}
class ServerImpl(context: AutowireContext) extends Api {
def echo(s: String) : String = {
s"Received on server: $s from IP: ${context.playRequest.remoteAddress}"
}
In "routes" add:
POST /api/*path controllers.Application.api(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment