aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/WebServer.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-01 15:20:05 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-01 15:20:05 +1300
commitef2ae4103726dae12a0153886219d4ac43d20ae0 (patch)
tree79291f74ce2631a4a9a176b7e510028e534a23d4 /src/org/traccar/web/WebServer.java
parentc6692703c8099577cb86c3eace5d8d1bc11f212d (diff)
parent53f70085891cdb0feae56df8990c1245091352a1 (diff)
downloadtraccar-server-ef2ae4103726dae12a0153886219d4ac43d20ae0.tar.gz
traccar-server-ef2ae4103726dae12a0153886219d4ac43d20ae0.tar.bz2
traccar-server-ef2ae4103726dae12a0153886219d4ac43d20ae0.zip
Merge branch 'rest' into master
Diffstat (limited to 'src/org/traccar/web/WebServer.java')
-rw-r--r--src/org/traccar/web/WebServer.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index f5a6acdd9..317e4db46 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -24,7 +24,13 @@ import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.webapp.WebAppContext;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletContainer;
import org.traccar.Config;
+import org.traccar.api.CorsResponseFilter;
+import org.traccar.api.SecurityRequestFilter;
+import org.traccar.api.resource.DeviceResource;
+import org.traccar.api.resource.UserResource;
import org.traccar.helper.Log;
/**
@@ -101,6 +107,12 @@ public class WebServer {
}
private void initApi() {
+ initOldApi();
+ initRestApi();
+ }
+
+ @Deprecated
+ private void initOldApi() {
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletHandler.setContextPath("/api");
servletHandler.addServlet(new ServletHolder(new AsyncServlet()), "/async/*");
@@ -120,6 +132,17 @@ public class WebServer {
handlers.addHandler(servletHandler);
}
+ private void initRestApi() {
+ ResourceConfig resourceConfig = new ResourceConfig();
+ resourceConfig.register(SecurityRequestFilter.class);
+ resourceConfig.register(CorsResponseFilter.class);
+ resourceConfig.registerClasses(DeviceResource.class, UserResource.class);
+ ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
+ ServletHolder servletHolder = new ServletHolder(new ServletContainer(resourceConfig));
+ servletHandler.addServlet(servletHolder, "/rest/*");
+ handlers.addHandler(servletHandler);
+ }
+
public void start() {
try {
server.start();