Skip to content

Instantly share code, notes, and snippets.

@ksky
Created January 28, 2010 13:23
Show Gist options
  • Save ksky/288732 to your computer and use it in GitHub Desktop.
Save ksky/288732 to your computer and use it in GitHub Desktop.
fully groovy web server
@Grab('org.eclipse.jetty:jetty-server:7.0.1.v20091125')
@Grab('org.eclipse.jetty:jetty-servlet:7.0.1.v20091125')
import org.eclipse.jetty.server.*
import org.eclipse.jetty.server.handler.*
import org.eclipse.jetty.servlet.*
import groovy.servlet.*
server = new Server(8080)
servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS)
servletHandler.with {
resourceBase = '.'
contextPath = '/'
addServlet(GroovyServlet, '*.groovy')
addServlet(TemplateServlet, '*.gtpl')
}
resourceHandler = new ResourceHandler(
resourceBase:".", welcomeFiles:['index.html'], directoriesListed:true)
server.handler = new HandlerList(handlers:[servletHandler, resourceHandler])
server.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment