Created
January 20, 2011 04:29
-
-
Save jpertino/787393 to your computer and use it in GitHub Desktop.
a simple embedded jetty server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.mortbay.jetty:jetty-embedded:6.1.26') | |
import static org.mortbay.jetty.Handler.DEFAULT | |
import org.mortbay.jetty.Server | |
import org.mortbay.jetty.servlet.Context | |
import org.mortbay.jetty.servlet.DefaultServlet | |
import org.mortbay.servlet.MultiPartFilter | |
import groovy.servlet.GroovyServlet | |
import groovy.servlet.TemplateServlet | |
new Server(80).with { | |
new Context(it, '/', Context.SESSIONS).with { | |
resourceBase = '.' | |
addFilter MultiPartFilter, '/*', DEFAULT | |
addServlet(DefaultServlet, '/static/*').with { | |
setInitParameter 'dirAllowed', 'true' | |
} | |
addServlet(TemplateServlet, '/view/*').with { | |
setInitParameter 'resource.name.regex', '/view(.*)' | |
setInitParameter 'resource.name.replacement', 'gsp/$1.gsp' | |
} | |
addServlet(GroovyServlet, '/groovy/*').with { | |
setInitParameter 'resource.name.regex', '/groovy(.*)' | |
setInitParameter 'resource.name.replacement', 'groovy/$1.groovy' | |
} | |
} | |
start() | |
join() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great! thanks.