Skip to content

Instantly share code, notes, and snippets.

@hanxue
Created February 12, 2014 09:12
Show Gist options
  • Save hanxue/8952231 to your computer and use it in GitHub Desktop.
Save hanxue/8952231 to your computer and use it in GitHub Desktop.
Proxy implemented using Play Framework
package controllers
import play.api.mvc.{Action, Controller}
import play.api.libs.ws.WS
import play.api.libs.concurrent.Execution.Implicits._
object Proxy extends Controller {
def index(url: String) = Action.async {
WS.url(url).get().map(resp => Ok(resp.body).as("text/html"))
}
}
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
GET /proxy controllers.Proxy.index(url)
@alexec
Copy link

alexec commented Mar 5, 2017

Brilliant. I will copy this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment