URL Traversal in Lift Framework

118 Views Asked by At

When I was using Pyramid Framework, I has discovered great method to route urls, named traversal.

Pyramid Traversal first maps request path to the traversal sequence (for example '/a/b/c' => [u'a', u'b', u'c']), and then traverse it consecutive through resources graph.

I am looking for some library or appoach for doing URL traversal in Lift.

1

There are 1 best solutions below

0
On

If there is no such library, the basics would not be that hard to implement.

Pseudocode:

//handlers is a hashtable which maps resource class -> handler function

my_catchall_route_handler( url )
{
    context = My_root_resource()
    for segment in split(url)
        try
           context = context.get_child( segment ) //try to get child resource
        except
           break //found ultimate context
    handler = handlers(context)
    handler();
}