Expand description
The core logic of drought
.
A Droughter
acts as a single layer of directories. It may also be called
by consumers, as the root of a given directory tree. It keeps track of a set
of Drought
trait objects. This allows for the manual implementation of
more structured router extensions, but drought
provides facilities
for simply adding a stateless lambda function, in the case of simpler needs.
Droughts
Each Drought
in a Droughter
has a given priority, and all droughts of
a given priority will be tested, before those of lower priority. If a
Drought
returns a DroughtResult::NotFound
, the next Drought
will be
checked. Otherwise, the DroughtResult
will be returned up through the
chain of Droughter
s that led to it being called. It should be noted that
the responsibility of deciding what resources to handle is down to the
discretion of each individual Drought
, and that a Drought
may choose to
serve any arbitrary number of resources.
Subdirectories are handled by special Drought
s, which wrap an internal
Droughter
. They may be created via the insert_sub
,
insert_typed
, and insert_matched
DroughterBuilder
methods.
DroughtResult
is crucial to the internal logic of drought
, and any
consumers should take time to read its documentation.
Irrigators
As a request travels down the set of Droughters
, and responses up again,
they will be passed through Irrigator
s. Irrigator
s allow for better
code reuse, as well as more efficient implementations of authentication,
caching, and so on. They are stored per-Droughter
.
RequestIrrigator
s act as transformers for incoming requests. They may
insert headers, rewrite URLs, and even insert an early reply. See IrrigatorResult
for more information on what they can alter.
ResponseIrrigator
s act as transformers for outgoing responses. They
get a mutable reference to the DroughtResult
returned by the previously
called Drought
, and may alter it as they see fit. In particular, the
macro system uses this to insert proper 404 pages, as opposed to the
empty default.
Structs
Droughter
.Drought
s.