Class
CogHostRoutesHandler
Description [src]
final class Cog.HostRoutesHandler : GObject.Object {
/* No available fields */
}
Direct custom URI scheme requests to different handlers.
Handler for custom URI scheme requests that can route requests to different handlers depending on the host component of the requested URI.
Optionally, if a “fallback” handler has been specified, it will be used to serve requests which do not match any of the routed hosts.
The set of available host routes entries can be configured using cog_host_routes_handler_add() and cog_host_routes_handler_remove(). For each request, route entries are checked and the one that matches the URI host component will handle the request.
This handler is typically used in tandem with
CogDirectoryFilesHandler
, the latter being typically a
fallback, or as the handler for a routed host.
The following configures a handler to route requests with their host
matching example.host
to a certain directory, and all the rest of
hosts to another directory:
GFile *fallback_dir = g_file_new_for_path ("data/default");
CogRequestHandler *fallback_handler = cog_directory_files_handler_new (fallback_dir);
GFile *example_host_dir = g_file_new_for_path ("data/example");
CogRequestHandler *example_host_handler = cog_directory_files_handler_new (example_host_handler);
CogRequestHandler *handler = cog_host_routes_handler_new (fallback_handler);
cog_host_routes_handler_add (COG_HOST_ROUTES_HANDLER (handler),
"example.host",
example_host_handler);
Instance methods
cog_host_routes_handler_add
Adds a route to the handler.
cog_host_routes_handler_add_path
Adds a route to the handler pointing to a directory.
cog_host_routes_handler_contains
Check if there is already added a route for the host
.
cog_host_routes_handler_remove
Removes a previously configured route.
Methods inherited from CogRequestHandler (1)
cog_request_handler_run
Handle a single custom URI scheme request.
Properties
Cog.HostRoutesHandler:fallback-handler
Optional CogRequestHandler
used as fallback when no route entries match
the URI host.
Class structure
struct CogHostRoutesHandlerClass {
GObjectClass parent_class;
}
Class members
parent_class |
|
No description available. |
Functions
cog_host_routes_handler_new
Create a new handler.