Added GroovyDirectoryServer: Simple file and Groovlet server..
This commit is contained in:
parent
1d3f8d71e2
commit
5edf144d3b
@ -2,7 +2,7 @@ apply plugin: "groovy"
|
|||||||
apply plugin: "maven"
|
apply plugin: "maven"
|
||||||
|
|
||||||
group = "com.jdbernard"
|
group = "com.jdbernard"
|
||||||
version = "3.8"
|
version = "3.9"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral() }
|
mavenCentral() }
|
||||||
@ -12,6 +12,7 @@ dependencies {
|
|||||||
compile 'org.slf4j:slf4j-api:1.7.10'
|
compile 'org.slf4j:slf4j-api:1.7.10'
|
||||||
compile 'ch.qos.logback:logback-core:1.1.2'
|
compile 'ch.qos.logback:logback-core:1.1.2'
|
||||||
compile 'ch.qos.logback:logback-classic: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'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
33
src/main/groovy/com/jdbernard/net/GroovyDirectoryServer.groovy
Executable file
33
src/main/groovy/com/jdbernard/net/GroovyDirectoryServer.groovy
Executable 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]))
|
Loading…
Reference in New Issue
Block a user