This class allows you to do route requests based on the HTTP verb and
the request URI, in a manner similar to <a
href="http://www.sinatrarb.com/">Sinatra</a> or <a
href="http://expressjs.com/">Express</a>.
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.
|
|
|
|
|
input(self,
request)
This method is called to provide the matcher with data. |
source code
|
|
|
get(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP GET |
source code
|
|
|
put(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP PUT |
source code
|
|
|
post(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP POST |
source code
|
|
|
delete(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP DELETE |
source code
|
|
|
options(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP OPTIONS |
source code
|
|
|
head(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP HEAD |
source code
|
|
|
trace(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP TRACE |
source code
|
|
|
patch(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP PATCH |
source code
|
|
|
connect(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP CONNECT |
source code
|
|
|
all(self,
pattern,
handler)
Specify a handler that will be called for any matching HTTP request |
source code
|
|
|
get_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP GET |
source code
|
|
|
put_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP PUT |
source code
|
|
|
post_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP POST |
source code
|
|
|
delete_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP DELETE |
source code
|
|
|
options_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP OPTIONS |
source code
|
|
|
head_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP HEAD |
source code
|
|
|
trace_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP TRACE |
source code
|
|
|
patch_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP PATCH |
source code
|
|
|
connect_re(self,
pattern,
handler)
Specify a handler that will be called for a matching HTTP CONNECT |
source code
|
|
|
all_re(self,
pattern,
handler)
Specify a handler that will be called for any matching HTTP request |
source code
|
|
|
no_match(self,
handler)
Specify a handler that will be called when nothing matches Default
behaviour is to return a 404 |
source code
|
|