VideoTools
|
A configuration structure for resources that Gv::HttpServerPeer makes available. More...
#include <gvhttpserver.h>
Public Member Functions | |
HttpServerResources () | |
Default constructor. | |
void | setDirectory (const G::Path &) |
Sets a directory for file resources. | |
void | addFileAny () |
Allow any file in the directory. | |
std::string | addFile (const G::Path &) |
Adds a file resource. More... | |
void | addFileType (const G::Path &, const std::string &type) |
Adds a filename-to-type mapping that overrides the extension mapping. More... | |
void | addChannel (const std::string &channel_name) |
Adds a channel resource. | |
void | addChannelAny () |
Adds the wildcard channel. | |
std::string | setDefault (const std::string &) |
Sets the default resource. Returns a warning string. | |
bool | empty () const |
Returns true if just default-constructed with no "add" or "set" methods called. More... | |
std::vector< std::string > | channels () const |
Returns a list of added channel names. | |
bool | anyChannel () const |
Returns true if addChannelAny() called. | |
bool | fileResource (const G::Path &url_path) const |
Returns true if the url path is for a file (eg. "/index.html"). | |
bool | channelResource (const G::Path &url_path) const |
Returns true if the url path is for a channel (eg. "/_foo"). | |
bool | specialResource (const G::Path &url_path) const |
Returns true if the url path is for a special resource (eg. "/__"). | |
std::string | fileResourcePath (const G::Path &url_path) const |
Returns the file-system path for the given url path, or the empty string if there is no matching resource map entry. More... | |
std::string | fileResourceType (const G::Path &url_path) const |
Returns the content-type path for the given url path, or the empty string if there is no matching resource map entry. More... | |
std::pair< std::string, std::string > | fileResourcePair (const G::Path &url_path) const |
Returns fileResourcePath() and fileResourceType() as a pair. More... | |
std::string | channelName (const G::Path &url_path) const |
Returns the channel name for the given channel-like url path. More... | |
void | log () const |
Emits diagnostic logging for the configured resources. | |
Static Public Member Functions | |
static std::string | guessType (const G::Path &path) |
Returns a probable content-type based on the filename, or the empty string. More... | |
A configuration structure for resources that Gv::HttpServerPeer makes available.
Definition at line 169 of file gvhttpserver.h.
std::string Gv::HttpServerResources::addFile | ( | const G::Path & | path_in | ) |
Adds a file resource.
Returns the empty string or a failure reason.
Definition at line 239 of file gvhttpserver.cpp.
void Gv::HttpServerResources::addFileType | ( | const G::Path & | path_in, |
const std::string & | type | ||
) |
Adds a filename-to-type mapping that overrides the extension mapping.
Definition at line 252 of file gvhttpserver.cpp.
std::string Gv::HttpServerResources::channelName | ( | const G::Path & | url_path | ) | const |
Returns the channel name for the given channel-like url path.
Precondition: channelResource(url_path)
Definition at line 298 of file gvhttpserver.cpp.
bool Gv::HttpServerResources::empty | ( | ) | const |
Returns true if just default-constructed with no "add" or "set" methods called.
Definition at line 275 of file gvhttpserver.cpp.
std::pair< std::string, std::string > Gv::HttpServerResources::fileResourcePair | ( | const G::Path & | url_path | ) | const |
Returns fileResourcePath() and fileResourceType() as a pair.
If not a valid fileResourcePath() then the reason is returned in the second part.
Definition at line 361 of file gvhttpserver.cpp.
std::string Gv::HttpServerResources::fileResourcePath | ( | const G::Path & | url_path | ) | const |
Returns the file-system path for the given url path, or the empty string if there is no matching resource map entry.
Precondition: fileResource(url_path)
Definition at line 322 of file gvhttpserver.cpp.
std::string Gv::HttpServerResources::fileResourceType | ( | const G::Path & | url_path | ) | const |
Returns the content-type path for the given url path, or the empty string if there is no matching resource map entry.
Precondition: fileResource(url_path)
Definition at line 327 of file gvhttpserver.cpp.
|
static |
Returns a probable content-type based on the filename, or the empty string.
Definition at line 193 of file gvhttpserver.cpp.