|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.vertx.groovy.core.http.RouteMatcher
class RouteMatcher
This class allows you to do route requests based on the HTTP verb and the request URI, in a manner similar to Sinatra or Express.
RouteMatcher also lets you extract paramaters from the request URI either a simple pattern or using regular expressions for more complex matches. Any parameters extracted will be added to the requests parameters which will be available to you in your request handler.
It's particularly useful when writing REST-ful web applications.
To use a simple pattern to extract parameters simply prefix the parameter name in the pattern with a ':' (colon).
Different handlers can be specified for each of the HTTP verbs, GET, POST, PUT, DELETE etc.
For more complex matches regular expressions can be used in the pattern. When regular expressions are used, the extracted parameters do not have a name, so they are put into the HTTP request with names of param0, param1, param2 etc.
Multiple matches can be specified for each HTTP verb. In the case there are more than one matching patterns for a particular request, the first matching one will be used.
Instances of this class are not thread-safe
Method Summary | |
---|---|
void
|
all(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for all HTTP methods |
void
|
allWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for all HTTP methods |
groovy.lang.Closure
|
asClosure()
|
void
|
connect(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP CONNECT |
void
|
connectWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP CONNECT |
void
|
delete(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP DELETE |
void
|
deleteWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP DELETE |
void
|
get(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP GET |
void
|
getWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP GET |
void
|
head(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP HEAD |
void
|
headWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP HEAD |
void
|
noMatch(groovy.lang.Closure handler)
Specify a handler that will be called when no other handlers match. |
void
|
options(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP OPTIONS |
void
|
optionsWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP OPTIONS |
void
|
patch(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP PATCH |
void
|
patchWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP PATCH |
void
|
post(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP POST |
void
|
postWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP POST |
void
|
put(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP PUT |
void
|
putWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP PUT |
void
|
trace(java.lang.String pattern, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP TRACE |
void
|
traceWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
Specify a handler that will be called for a matching HTTP TRACE |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Method Detail |
---|
void all(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void allWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
groovy.lang.Closure asClosure()
void connect(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void connectWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
void delete(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void deleteWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
void get(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void getWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
void head(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void headWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
void noMatch(groovy.lang.Closure handler)
void options(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void optionsWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
void patch(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void patchWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
void post(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void postWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
void put(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void putWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
void trace(java.lang.String pattern, groovy.lang.Closure handler)
pattern
- The simple patternhandler
- The handler to call
void traceWithRegEx(java.lang.String regex, groovy.lang.Closure handler)
regex
- A regular expressionhandler
- The handler to call
Groovy Documentation