Added GroovyDirectoryServer: Simple file and Groovlet server..

This commit is contained in:
Jonathan Bernard 2015-07-07 13:28:22 -05:00
parent 1d3f8d71e2
commit 5edf144d3b
2 changed files with 35 additions and 1 deletions

View File

@ -2,7 +2,7 @@ apply plugin: "groovy"
apply plugin: "maven"
group = "com.jdbernard"
version = "3.8"
version = "3.9"
repositories {
mavenCentral() }
@ -12,6 +12,7 @@ dependencies {
compile 'org.slf4j:slf4j-api:1.7.10'
compile 'ch.qos.logback:logback-core:1.1.2'
compile 'ch.qos.logback:logback-classic:1.1.2'
compile 'org.eclipse.jetty.aggregate:jetty-all:7.6.15.v20140411'
testCompile 'junit:junit:4.12'
}

View File

@ -0,0 +1,33 @@
#!/usr/bin/env groovy
package com.jdbernard.net
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.*
import groovy.servlet.*
def startJetty(int port) {
def server = new Server(port)
def handler = new ServletContextHandler(ServletContextHandler.SESSIONS)
handler.contextPath = '/'
handler.resourceBase = '.'
// Groovy Scripts
handler.addServlet(GroovyServlet, '*.groovy')
// Files
def filesHolder = handler.addServlet(DefaultServlet, '/')
filesHolder.setInitParameter('resourceBase', '.')
server.handler = handler
server.start()
}
if (args.length < 1) {
println "Usage: webServer.groovy <port>"
System.exit(1) }
println "Starting Jetty, press Ctrl-C to stop."
startJetty(Integer.parseInt(args[0]))