Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save leobm/b0f23a626803100fbe531f3d4b348606 to your computer and use it in GitHub Desktop.
Save leobm/b0f23a626803100fbe531f3d4b348606 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