Browse Source

Pass original URI through to endpoint handlers.

Matt Clark 10 months ago
parent
commit
1e63c1ce7d

+ 1 - 1
src/main/java/org/barcodeapi/server/admin/CacheDumpHandler.java

@@ -21,7 +21,7 @@ public class CacheDumpHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		// loop all caches

+ 1 - 1
src/main/java/org/barcodeapi/server/admin/CacheFlushHandler.java

@@ -18,7 +18,7 @@ public class CacheFlushHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		JSONObject counts = new JSONObject();

+ 1 - 1
src/main/java/org/barcodeapi/server/admin/ConfigReloadHandler.java

@@ -18,7 +18,7 @@ public class ConfigReloadHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		Authlist.reload();

+ 1 - 1
src/main/java/org/barcodeapi/server/admin/SessionFlushHandler.java

@@ -17,7 +17,7 @@ public class SessionFlushHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		double count = SessionCache.getCache().clearCache();

+ 1 - 1
src/main/java/org/barcodeapi/server/admin/SessionListHandler.java

@@ -18,7 +18,7 @@ public class SessionListHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		JSONArray sessions = new JSONArray();

+ 1 - 1
src/main/java/org/barcodeapi/server/api/AboutHandler.java

@@ -17,7 +17,7 @@ public class AboutHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		// print response to client

+ 1 - 2
src/main/java/org/barcodeapi/server/api/BarcodeAPIHandler.java

@@ -34,11 +34,10 @@ public class BarcodeAPIHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		CachedBarcode barcode;
-		String uri = request.getRequestURI();
 
 		try {
 

+ 1 - 1
src/main/java/org/barcodeapi/server/api/BulkHandler.java

@@ -22,7 +22,7 @@ public class BulkHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws ServletException, IOException {
 
 		// Setup accept multi-part

+ 1 - 1
src/main/java/org/barcodeapi/server/api/SessionDetailsHandler.java

@@ -15,7 +15,7 @@ public class SessionDetailsHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		// print response to client

+ 1 - 1
src/main/java/org/barcodeapi/server/api/StaticHandler.java

@@ -43,7 +43,7 @@ public class StaticHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 	}
 }

+ 1 - 1
src/main/java/org/barcodeapi/server/api/StatsHandler.java

@@ -15,7 +15,7 @@ public class StatsHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		// print response to client

+ 1 - 1
src/main/java/org/barcodeapi/server/api/TypesHandler.java

@@ -18,7 +18,7 @@ public class TypesHandler extends RestHandler {
 	}
 
 	@Override
-	protected void onRequest(HttpServletRequest request, HttpServletResponse response)
+	protected void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
 			throws JSONException, IOException {
 
 		// loop all supported types

+ 4 - 2
src/main/java/org/barcodeapi/server/core/RestHandler.java

@@ -127,7 +127,8 @@ public abstract class RestHandler extends AbstractHandler {
 		try {
 
 			// call the implemented method
-			this.onRequest(request, response);
+			String uri = baseRequest.getOriginalURI();
+			this.onRequest(uri, request, response);
 		} catch (Exception e) {
 
 			// TODO handle this
@@ -140,7 +141,8 @@ public abstract class RestHandler extends AbstractHandler {
 		getStats().hitCounter(targetTime, "request", "target", _NAME, "time");
 	}
 
-	protected abstract void onRequest(HttpServletRequest request, HttpServletResponse response) throws Exception;
+	protected abstract void onRequest(String uri, HttpServletRequest request, HttpServletResponse response)
+			throws Exception;
 
 	protected void addCORSHeaders(HttpServletRequest request, HttpServletResponse response) {