Public Member Functions | |
constructor ?newOpts? | |
config name args | |
log request response | |
router | |
route method pattern host args | |
forget sock | |
close sock | |
error e sock | |
respond event sock | |
accept sock addr port | |
listen port | |
Static Public Attributes | |
name | |
version | |
tanzer::server::constructor | ?newOpts? | ||
Create a new server, with optional $newOpts
list of pairs indicating configuration. Accepted values are:
proto
The protocol to accept connections for. Defaults to http
, but can be scgi
.
readsize
Defaults to 4096. The size of buffer used to read from remote sockets and local files.
logger
Defaults to the simple standard output logger provided in ::tanzer::logger::default. Any command or object that provides log
and err
subcommands is suitable; a no-op proc is also useful for suppressing logging altogether.
tanzer::server::accept | sock addr port | ||
Accepts an inbound connection as a callback to [socket -server]
. Creates a new tanzer::session object associated with $sock
, and installs the server's default event handler for $sock
for only read
events, initially.
Use this method directly if you intend to listen on multiple sockets, a different host address, or if you wish to use ::tls::socket to create a listener instead.
tanzer::server::close | sock | ||
Close socket $sock
, destroy the associated session handler, and forget about the socket and session handler.
tanzer::server::config | name args | ||
Query configuration value $name
from server, or set configuration for $name
with a second argument provided as value.
tanzer::server::error | e sock | ||
Serve the error message $e
for the session associated with $sock
, and immediately end the session and close the socket.
tanzer::server::forget | sock | ||
Make the server completely forget about $sock
. The server will forget about the session handler associated with the socket.
tanzer::server::listen | port | ||
Listen for inbound connections on $port
, and enter the socket handling event loop. This simply creates a new listener with [socket -server]
and dispatches all inbound connections to tanzer::server::accept.
Do not use this if you intend to listen to listen on multiple sockets, or if you wish to use TLS.
tanzer::server::respond | event sock | ||
The default I/O event handler associated with new connection sockets opened by the server. $event
is one of read
or write
. Not meant to be called directly.
tanzer::server::route | method pattern host args | ||
Route a request handler to the server. Arguments are as follows:
$method
A non-anchored regular expression performing a case insensitive match on the incoming HTTP request method. Anchoring is performed by the request route matching engine.
$pattern
A URI path, containing any number of path components describing named parameters in the :param
style. Paths ending with *
will match any incoming URI path parts before the glob.
$host
A non-anchored regular expression performing a case insensitive match on the incoming HTTP Host: request header. Anchoring is performed by the request route matching engine.
$args
Any number of arguments desribing the request handler to be dispatched for requests that match the route described by an invocation to this method.
The following arguments will be appended to the script specified in $args
:
read
or write
, indicating the session socket is ready to be read from or written totanzer::session
objectread
event, a chunk of data read from the request bodytanzer::server::router |
Return the routing table object the server is currently using.