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);

Ancestors

Implements

Functions

cog_host_routes_handler_new

Create a new 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 GObject (43)

Please see GObject for a full list of methods.

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.

Signals

Signals inherited from GObject (1)
GObject.Object::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct CogHostRoutesHandlerClass {
  GObjectClass parent_class;
  
}
Class members
parent_class
GObjectClass
  No description available.