Groovy Documentation

## org.vertx.groovy.core.http
[Groovy] Class RouteMatcher

    java.lang.Object
      org.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

Authors:
  Tim Fox

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()`

Returns:
  Convert to a Closure so can be passed to (e.g.)

`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

### all

    void all(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for all HTTP methods
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### allWithRegEx

    void allWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for all HTTP methods
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### asClosure

    groovy.lang.Closure asClosure()

  Returns:
    Convert to a Closure so can be passed to (e.g.) HttpServer requestHandler

### connect

    void connect(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP CONNECT
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### connectWithRegEx

    void connectWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP CONNECT
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### delete

    void delete(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP DELETE
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### deleteWithRegEx

    void deleteWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP DELETE
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### get

    void get(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP GET
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### getWithRegEx

    void getWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP GET
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### head

    void head(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP HEAD
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### headWithRegEx

    void headWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP HEAD
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### noMatch

    void noMatch(groovy.lang.Closure handler)

  Specify a handler that will be called when no other handlers match. If this handler is not specified default behaviour is to return a 404
  Parameters:
    handler

### options

    void options(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP OPTIONS
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### optionsWithRegEx

    void optionsWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP OPTIONS
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### patch

    void patch(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP PATCH
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### patchWithRegEx

    void patchWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP PATCH
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### post

    void post(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP POST
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### postWithRegEx

    void postWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP POST
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### put

    void put(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP PUT
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### putWithRegEx

    void putWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP PUT
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

### trace

    void trace(java.lang.String pattern, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP TRACE
  Parameters:
    `pattern` - The simple pattern
    `handler` - The handler to call

### traceWithRegEx

    void traceWithRegEx(java.lang.String regex, groovy.lang.Closure handler)

  Specify a handler that will be called for a matching HTTP TRACE
  Parameters:
    `regex` - A regular expression
    `handler` - The handler to call

Groovy Documentation