Created
April 18, 2012 22:19
-
-
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
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
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