forked from moquette-io/moquette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launghLocalJetty.groovy
30 lines (23 loc) · 1.03 KB
/
launghLocalJetty.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@Grab(group='org.eclipse.jetty.aggregate', module='jetty-server', version='8.1.16.v20140903')
@Grab(group='javax.servlet', module='javax.servlet-api', version='3.0.1')
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.server.nio.SelectChannelConnector
import org.eclipse.jetty.server.handler.ResourceHandler
import org.eclipse.jetty.server.handler.HandlerList
import org.eclipse.jetty.server.handler.DefaultHandler
import org.eclipse.jetty.server.Handler
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
//resource_handler.setWelcomeFiles(["index.html"] as new String[0]);
resource_handler.setResourceBase(".");
HandlerList handlers = new HandlerList();
handlers.addHandler(resource_handler)
handlers.addHandler(new DefaultHandler());
server.setHandler(handlers);
server.start();
println "Local server started"
server.join();