Skip to content

Instantly share code, notes, and snippets.

@ppurang
Created April 18, 2012 22:19
Show Gist options
  • Save ppurang/2417023 to your computer and use it in GitHub Desktop.
Save ppurang/2417023 to your computer and use it in GitHub Desktop.
Play 2.0 Make Global onRouteRequest use a particular controller action if a specific header is there edit
import controllers.{routes, Application}
import play.api._
import play.api.mvc._
import play.api.mvc.Results._
import play.api.Play.current
import controllers.Utils._
object Global extends GlobalSettings {
override def onRouteRequest(request: RequestHeader): Option[Handler] = {
if (request.headers.toMap.filter(x => x._1.toLowerCase.contains("propfind")).isEmpty) { //i'd refactor this into something better
super.onRouteRequest(request) //if no proprfind in the headers do the ususal thing
} else {
Some(Application.pi()) // or else call an action
}
}
}
//test
//curl "http://localhost:9000/wwwww"
//curl -H "propfind: coolaid" "http://localhost:9000/wwwww"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment