views:

23

answers:

1

I have a Groovy Web application which is NOT being deployed on Google app engine. (GAE) I have used Gaelyk before and I like the URL routing functionality described in their doc

How do I port over just the routing functionality from Gaelyk to my basic Groovy WEB application which is not being deployed on GAE?

Note 1: I also do not want to use Grails for this application.

Note 2: I dont mind including the gaelyk jar but I rather not include anything from GAE.

+1  A: 

If you want to implement this yourself in your own non GAE framework, the best place to start would be the source...

To start with, you'll need a class that extends javax.servlet.Filter in Gaelyk, this is the RoutesFilter class

As you can see, in the init method of the Filter, this calls loadRoutes which loads your routes.groovy script via a GroovyShell.

This shell makes use of the other classes in that same package so that it ends up populating the List<Route> routes property in the filter with instance of the Route class.

The filter (when configured by web.xml) then intercepts all requests to the server checks the URI against each route in turn (by calling the forUri method for each route), and if a match is found, it redirects or forwards as required.

If no match is found the Filter calls the next filter down the chain in the web server's context.

Hope this answers your question

tim_yates