Static and dynamic repositories of resources in an httpd.
- class HostMapper α where
- findResourceMap :: Host -> α -> MaybeT IO ResourceMap
- hostMap :: α -> HostMap
- data HostMap
- class ResourceMapper α where
- findResource :: Path -> α -> MaybeT IO (Path, Resource)
- resourceMap :: α -> ResourceMap
- data ResourceMap
- data ResourceTree
- data ResourceNode
- greedy :: Resource -> ResourceNode
- nonGreedy :: Resource -> ResourceNode
Documentation
class HostMapper α whereSource
Class of maps from Host
to ResourceMap
to provide name-based
virtual hosts.
Note that Lucu currently does not implement neither RFC 2817 connection upgrading (http://tools.ietf.org/html/rfc2817) nor RFC 3546 server name indication (http://tools.ietf.org/html/rfc3546#section-3.1) so you won't be able to host more than one SSL virtual host on the same port without using wildcard certificates (http://tools.ietf.org/html/rfc2818#section-3.1).
Minimal complete definition: findResourceMap
findResourceMap :: Host -> α -> MaybeT IO ResourceMapSource
Find a repository of resources for the given host name if any.
Wrap an instance of HostMapper
in a monoidal, homogeneous
container.
Map α Host ResourceMap => HostMapper α | Any |
HostMapper ResourceMap |
|
HostMapper HostMap | |
HostMapper (Host -> Maybe ResourceMap) | A pure host mapper. |
HostMapper (Host -> MaybeT IO ResourceMap) | An IO-based host mapper. |
Container type for the HostMapper
type class.
Monoid HostMap |
|
HostMapper HostMap | |
HostMapper α => Unfoldable HostMap α |
|
class ResourceMapper α whereSource
Class of maps from resource Path
to Resource
.
Minimal complete definition: findResource
findResource :: Path -> α -> MaybeT IO (Path, Resource)Source
Find a resource handler for the given resource path, along
with the path where the said handler was found. The found path
is usually the same as the queried path, but there are
situations where the found path is just a prefix of the queried
path. See greedy
.
resourceMap :: α -> ResourceMapSource
Wrap an instance of ResourceMapper
in a monoidal,
homogeneous container.
Map α Path (Path, Resource) => ResourceMapper α | Any |
ResourceMapper ResourceTree |
|
ResourceMapper ResourceMap | |
ResourceMapper (Path -> Maybe (Path, Resource)) | A pure resource mapper. |
ResourceMapper (Path -> MaybeT IO (Path, Resource)) | An IO-based resource mapper. |
data ResourceMap Source
Container type for the ResourceMapper
type class.
Monoid ResourceMap |
|
ResourceMapper ResourceMap | |
HostMapper ResourceMap |
|
ResourceMapper α => Unfoldable ResourceMap α |
|
HostMapper (Host -> Maybe ResourceMap) | A pure host mapper. |
HostMapper (Host -> MaybeT IO ResourceMap) | An IO-based host mapper. |
data ResourceTree Source
ResourceTree
is an opaque structure which a map from resource
Path
to ResourceNode
.
fromList
[ ([] ,nonGreedy
$
Network.HTTP.Lucu.StaticFile.staticFile
"/usr/include/stdio.h" ) -- / , (["unistd"],nonGreedy
$
Network.HTTP.Lucu.StaticFile.staticFile
"/usr/include/unistd.h") -- /unistd ]
Note that path segments are always represented as octet streams in this system. Lucu automatically decodes percent-encoded URIs but has no involvement in character encodings such as UTF-8, since RFC 2616 (HTTP/1.1) says nothing about character encodings to be used in "http" and "https" URI schemas.
Monoid ResourceTree | |
ResourceMapper ResourceTree |
|
Collection ResourceTree (Path, ResourceNode) | |
Unfoldable ResourceTree (Path, ResourceNode) | |
Foldable ResourceTree (Path, ResourceNode) |
data ResourceNode Source
A node of Resource
located somewhere in a ResourceTree
. Such
nodes are either greedy
or nonGreedy
.
Collection ResourceTree (Path, ResourceNode) | |
Unfoldable ResourceTree (Path, ResourceNode) | |
Foldable ResourceTree (Path, ResourceNode) |
greedy :: Resource -> ResourceNodeSource
Make a greedy resource node.
Say a client is trying to access "/aaa/bbb/ccc' while there is no resource node at the path. If there are greedy resource nodes at "/aaa/bbb", "/aaa" or "/" they will be chosen instead as a fallback. Greedy resource nodes are searched in depth-first order, just like CGI scripts.
nonGreedy :: Resource -> ResourceNodeSource
Make a normal, non-greedy resource node.