Created
June 26, 2014 10:09
-
-
Save pledbrook/9e1e6e0e1a520b6a3612 to your computer and use it in GitHub Desktop.
Trying to redirect all paths below a given prefix (GET only)
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
ratpack { | |
... | |
handlers { | |
get { | |
... | |
} | |
prefix("blog") { | |
handler { | |
redirect 303, "http://blog.cacoethes.co.uk/${get(PathBinding).pastBinding}" | |
} | |
} | |
assets "public" | |
} | |
} |
You have it right...
prefix("blog") {
handler {
byMethod {
get {
...
}
}
}
}
This is the right approach.
@pledbrook I see, didn't realize what you were doing with the remainder of the path there
@danveloper The first time I tried that the app was hanging, which is why I resorted to Help By Twitter. Still, it seems unnecessarily verbose and confusing. Not sure why byMethod()
isn't a handler itself.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@robfletcher Apparently
handler(path, ...)
only triggers if the path matches exactly (so says the [API docs](http://www.ratpack.io/manual/current/api/ratpack/groovy/handling/GroovyChain.html#handler%28java.lang.String, groovy.lang.Closure%29) anyway). As far as I can tell,prefix()
is the only one that does a match on just the start of the path.