bleedingwolf / Ratpack

A micro web framework for Groovy
Other
210 stars 4 forks source link

Building a WAR file #9

Closed plusplus closed 13 years ago

plusplus commented 13 years ago

Hi - how would you go about building a WAR file for a ratpack app to drop into a servlet container? Apologies if this is newb - I'm more familiar with sinatra than groovy.

justinvoss commented 13 years ago

This isn't documented (yet), but you can do this by adding some parameters to your WAR's web.xml. Adding an init parameter called app-script-filename will cause the RatpackServlet to load your app from a Groovy script in your WEB-INF/lib folder. Here's a quick example:

<servlet>
  <servlet-name>Ratpack</servlet-name>
  <servlet-class>com.bleedingwolf.ratpack.RatpackServlet</servlet-class>
  <init-param> 
    <param-name>app-script-filename</param-name> 
    <param-value>yourApp.groovy</param-value> 
  </init-param> 
</servlet>

Assuming the file WEB-INF/lib/yourApp.groovy exists and is a valid Ratpack app, this will create a servlet you can route requests to and have them handled by your app.

plusplus commented 13 years ago

Thanks for feedback! Unfortunately the powers that be have forced the app I'm working on to be a Grails app. Thanks for the good work :)