0

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.

Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80
Tihom
  • 3,384
  • 6
  • 36
  • 47
  • you are going to have to be more specific with what your problem is. The documentation explains how to use the mapping functionality... what specific implementation issue are you having? – Aaron Saunders Oct 08 '10 at 04:33
  • I want to take the routing aspect from gaelyk to use in a non-gaelyk app. – Tihom Oct 08 '10 at 14:53

1 Answers1

2

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

Community
  • 1
  • 1
tim_yates
  • 167,322
  • 27
  • 342
  • 338