diff options
author | Abyss777 <abyss@fox5.ru> | 2018-02-02 11:15:12 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2018-02-02 11:15:12 +0500 |
commit | 195ec5aed9e3a6a499cf5a21773235563806a0c1 (patch) | |
tree | 127cd931fe6d7403ed3a45d5f99f6a360dc78305 /src/org/traccar/web/WebServer.java | |
parent | 22f792139406e381fdda5a02a61b61a577b33656 (diff) | |
download | trackermap-server-195ec5aed9e3a6a499cf5a21773235563806a0c1.tar.gz trackermap-server-195ec5aed9e3a6a499cf5a21773235563806a0c1.tar.bz2 trackermap-server-195ec5aed9e3a6a499cf5a21773235563806a0c1.zip |
- Move media servlet to api context
- Cleanup and optimization
Diffstat (limited to 'src/org/traccar/web/WebServer.java')
-rw-r--r-- | src/org/traccar/web/WebServer.java | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 8b0696081..88b38c1ab 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,6 @@ public class WebServer { } initServer(); - initMedia(); initApi(); if (config.getBoolean("web.console")) { initConsole(); @@ -161,19 +160,6 @@ public class WebServer { handlers.addHandler(app); } - private void initMedia() { - ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); - servletHandler.setContextPath("/api/media"); - servletHandler.getSessionHandler().setSessionManager(sessionManager); - - ServletHolder servletHolder = new ServletHolder("media", DefaultServlet.class); - servletHolder.setInitParameter("resourceBase", config.getString("media.path")); - servletHolder.setInitParameter("dirAllowed", config.getString("media.dirAllowed", "false")); - servletHandler.addServlet(servletHolder, "/*"); - servletHandler.addFilter(MediaFilter.class, "/*", EnumSet.of(DispatcherType.INCLUDE, DispatcherType.REQUEST)); - handlers.addHandler(servletHandler); - } - private void initApi() { ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); servletHandler.setContextPath("/api"); @@ -181,11 +167,17 @@ public class WebServer { servletHandler.addServlet(new ServletHolder(new AsyncSocketServlet()), "/socket"); + ServletHolder servletHolder = new ServletHolder("media", DefaultServlet.class); + servletHolder.setInitParameter("resourceBase", config.getString("media.path")); + servletHolder.setInitParameter("dirAllowed", config.getString("media.directoryAllow", "false")); + servletHolder.setInitParameter("pathInfoOnly", "true"); + servletHandler.addServlet(servletHolder, "/media/*"); + servletHandler.addFilter(MediaFilter.class, "/media/*", EnumSet.allOf(DispatcherType.class)); + ResourceConfig resourceConfig = new ResourceConfig(); resourceConfig.registerClasses(JacksonFeature.class, ObjectMapperProvider.class, ResourceErrorHandler.class); resourceConfig.registerClasses(SecurityRequestFilter.class, CorsResponseFilter.class); resourceConfig.packages(ServerResource.class.getPackage().getName()); - servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*"); handlers.addHandler(servletHandler); |