Class

CogPrefixRoutesHandler

Description [src]

final class Cog.PrefixRoutesHandler : 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 prefix of the requested URI path component.

Optionally, if a “fallback” handler has been specified, it will be used to serve requests which do not match any of the routed prefixes.

The set of available prefix routes can be configured using cog_prefix_routes_handler_mount() and cog_prefix_routes_handler_unmount(). For each request, routes are checked and the one that matches the most URI path components 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 prefix.

The following configures a handler to route requests with their path starting with /static/images to a certain directory, and all the rest of paths to another—note how the CogDirectoryFilesHandler:strip-components property is used to remove the matched path components for that route:

GFile *content_dir = g_file_new_for_path ("data/content");
CogRequestHandler *fallback_handler = cog_directory_files_handler_new (content_dir);

GFile *images_dir = g_file_new_for_path ("data/images");
CogRequestHandler *images_handler = g_object_new (COG_TYPE_DIRECTORY_FILES_HANDLER,
                                                  "base-path", images_dir,
                                                  "strip-components", 2,
                                                  NULL);

CogRequestHandler *handler = cog_prefix_routes_handler_new (fallback_handler);
cog_prefix_routes_handler_mount (COG_PREFIX_ROUTES_HANDLER (handler),
                                 "/static/images",
                                 images_handler);

Ancestors

Implements

Functions

cog_prefix_routes_handler_new

Create a new handler.

Instance methods

cog_prefix_routes_handler_mount

Adds a route to the handler.

cog_prefix_routes_handler_mount_path

Adds a route to the handler pointing to a directory.

cog_prefix_routes_handler_unmount

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.PrefixRoutesHandler:fallback-handler

Optional CogRequestHandler used as fallback when no routes match the URI path.

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 CogPrefixRoutesHandlerClass {
  GObjectClass parent_class;
  
}
Class members
parent_class
GObjectClass
  No description available.