aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/WebServer.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-15 15:02:01 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-15 15:02:01 +1300
commit4113e28eda3df4725cc72527216a02d1b9cfed17 (patch)
tree75454f6873da40f13b4f2e1fe72591fdfe1037d9 /src/org/traccar/web/WebServer.java
parentf5ab3489c9abdc825dd5297829119813740e32e6 (diff)
downloadtrackermap-server-4113e28eda3df4725cc72527216a02d1b9cfed17.tar.gz
trackermap-server-4113e28eda3df4725cc72527216a02d1b9cfed17.tar.bz2
trackermap-server-4113e28eda3df4725cc72527216a02d1b9cfed17.zip
Enable only REST API by default
Diffstat (limited to 'src/org/traccar/web/WebServer.java')
-rw-r--r--src/org/traccar/web/WebServer.java33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index cd01d04b4..ebcdc7137 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -71,14 +71,14 @@ public class WebServer {
initServer();
switch (config.getString("web.type", "new")) {
case "api":
- initOldApi(false);
+ initApi();
break;
case "old":
- initOldApi(false);
+ initOldApi();
initOldWebApp();
break;
default:
- initOldApi(true);
+ initApi();
if (config.getBoolean("web.console")) {
initConsole();
}
@@ -122,19 +122,26 @@ public class WebServer {
handlers.addHandler(app);
}
- private void initOldApi(boolean initRest) {
+ private void initApi() {
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletHandler.setContextPath("/api");
- if (initRest) {
- ResourceConfig resourceConfig = new ResourceConfig();
- resourceConfig.register(ResourceErrorHandler.class);
- resourceConfig.register(SecurityRequestFilter.class);
- resourceConfig.register(CorsResponseFilter.class);
- resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class,
- PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class);
- servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/rest/*");
- }
+
servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket");
+
+ ResourceConfig resourceConfig = new ResourceConfig();
+ resourceConfig.register(ResourceErrorHandler.class);
+ resourceConfig.register(SecurityRequestFilter.class);
+ resourceConfig.register(CorsResponseFilter.class);
+ resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class,
+ PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class);
+ servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");
+
+ handlers.addHandler(servletHandler);
+ }
+
+ private void initOldApi() {
+ ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
+ servletHandler.setContextPath("/api");
servletHandler.addServlet(new ServletHolder(new AsyncServlet()), "/async/*");
servletHandler.addServlet(new ServletHolder(new ServerServlet()), "/server/*");
servletHandler.addServlet(new ServletHolder(new UserServlet()), "/user/*");