Tabs -> spaces.

This commit is contained in:
Jonathan Bernard 2015-09-24 08:36:34 -05:00
parent 23e8750171
commit 486e718eee

View File

@ -6,38 +6,38 @@ import groovy.servlet.*
public class GroovyDirectoryServer { public class GroovyDirectoryServer {
public static final String VERSION = "1.0" public static final String VERSION = "1.0"
public static void main(String[] args) { public static void main(String[] args) {
def port = 9002 def port = 9002
if (args.length < 1) { println "Defaulting to port 9002" } if (args.length < 1) { println "Defaulting to port 9002" }
else try { port = args[0] as int } else try { port = args[0] as int }
catch(Exception e) { catch(Exception e) {
println "Usage: GroovyDirectoryServer.grooy <port>" println "Usage: GroovyDirectoryServer.grooy <port>"
System.exit(1) } System.exit(1) }
println "Starting Jetty on port $port, press Ctrl-C to stop." println "Starting Jetty on port $port, press Ctrl-C to stop."
runJetty(port) runJetty(port)
} }
public static void runJetty(int port) { public static void runJetty(int port) {
def server = new Server(port) def server = new Server(port)
def handler = new ServletContextHandler(ServletContextHandler.SESSIONS) def handler = new ServletContextHandler(ServletContextHandler.SESSIONS)
handler.contextPath = '/' handler.contextPath = '/'
handler.resourceBase = '.' handler.resourceBase = '.'
// Groovy Scripts // Groovy Scripts
handler.addServlet(GroovyServlet, '*.groovy') handler.addServlet(GroovyServlet, '*.groovy')
// Files // Files
def filesHolder = handler.addServlet(DefaultServlet, '/') def filesHolder = handler.addServlet(DefaultServlet, '/')
filesHolder.setInitParameter('resourceBase', '.') filesHolder.setInitParameter('resourceBase', '.')
server.handler = handler server.handler = handler
server.start() server.start()
} }
} }