Last active
May 20, 2016 18:41
-
-
Save mkotsbak/122940aa003db9708093 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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