N-ary URL dispatcher

I'm not sure if this is useful to anyone, but I'd figure I would share
it anyway.

Code can be found here[1].

This is a simple URL router that might be useful to people who want to
do REST style URLs. It allows you to extract fields from the URL and
dispatch as a single step. It uses GNode (N-ary tree) to decompose the
possible URLs.

This means that each part of the URL path is another child node, some of
which can be "wildcards" allowing capturing before diving down to the
next child.

For example:


In a default handler in SoupServer [soup_server_add_handler()], you
simply call url_router_route(...).

The UrlRouterHandler callback provides an extra GHashTable that contains
the captured fields (in above example: "user", "device") if there were any.


-- Christian

[1] https://gist.github.com/4081826

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]