<NME> KVStorePlugin.java
<BEF> ADDFILE
<MSG> plugins for the HttpRouter

<DFF> @@ -0,0 +1,31 @@
+package com.platform.middlewares.plugins;
+
+import com.platform.interfaces.Plugin;
+
+/**
+ * BreadWallet
+ * <p/>
+ * Created by Mihail Gutan on <mihail@breadwallet.com> 11/1/16.
+ * Copyright (c) 2016 breadwallet LLC
+ * <p/>
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * <p/>
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * <p/>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+public class KVStorePlugin implements Plugin{
+    public static final String TAG = KVStorePlugin.class.getName();
+}

{'commit': 'diff --git a/app/src/androidTest/java/com/breadwallet/PlatformTests.java b/app/src/androidTest/java/com/breadwallet/PlatformTests.java\nindex 59e80d3cb..961e596d1 100644\n--- a/app/src/androidTest/java/com/breadwallet/PlatformTests.java\n+++ b/app/src/androidTest/java/com/breadwallet/PlatformTests.java\n@@ -92,7 +92,7 @@ public class PlatformTests {\n \n     @Test\n     public void testFeePerKbFetch() {\n-        long fee = APIClient.getInstance().feePerKb();\n+        long fee = APIClient.getInstance(mActivityRule.getActivity()).feePerKb();\n         System.out.println("testFeePerKbFetch: fee: " + fee);\n         Assert.assertNotSame(fee, (long) 0);\n \n@@ -106,7 +106,7 @@ public class PlatformTests {\n                 .get().build();\n \n         Response response = null;\n-        APIClient apiClient = APIClient.getInstance();\n+        APIClient apiClient = APIClient.getInstance(mActivityRule.getActivity());\n         response = apiClient.sendRequest(request, false);\n         apiClient.writeBundleToFile(response, bundleFile);\n         apiClient.tryExtractTar(bundleFile);\n@@ -126,7 +126,7 @@ public class PlatformTests {\n \n     @Test\n     public void bundleDownloadTest() {\n-        APIClient apiClient = APIClient.getInstance();\n+        APIClient apiClient = APIClient.getInstance(mActivityRule.getActivity());\n         Request request = new Request.Builder()\n                 .get()\n                 .url("https://s3.amazonaws.com/breadwallet-assets/bread-buy/7f5bc5c6cc005df224a6ea4567e508491acaffdc2e4769e5262a52f5b785e261.tar").build();\n@@ -145,7 +145,7 @@ public class PlatformTests {\n     @Test\n     public void bundleUpdateTest() {\n \n-        APIClient apiClient = APIClient.getInstance();\n+        APIClient apiClient = APIClient.getInstance(mActivityRule.getActivity());\n \n         Request request = new Request.Builder()\n                 .get()\n@@ -219,13 +219,13 @@ public class PlatformTests {\n \n     @Test\n     public void testGetToken() {\n-        APIClient apiClient = APIClient.getInstance();\n+        APIClient apiClient = APIClient.getInstance(mActivityRule.getActivity());\n         apiClient.getToken();\n     }\n \n     @Test\n     public void testMeRequest() {\n-        APIClient apiClient = APIClient.getInstance();\n+        APIClient apiClient = APIClient.getInstance(mActivityRule.getActivity());\n         String response = apiClient.buyBitcoinMe().toLowerCase();\n         String expectedString = "invalid signature";\n         Assert.assertNotEquals(response, expectedString);\ndiff --git a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentAbout.java b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentAbout.java\nindex 5041bb307..9306de1f7 100644\n--- a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentAbout.java\n+++ b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentAbout.java\n@@ -95,12 +95,12 @@ public class FragmentAbout extends Fragment {\n                 }\n             });\n \n-        new Thread(new Runnable() {\n-            @Override\n-            public void run() {\n-                APIClient.getInstance(getActivity()).buyBitcoinMe();\n-            }\n-        }).start();\n+//        new Thread(new Runnable() {\n+//            @Override\n+//            public void run() {\n+//                APIClient.getInstance(getActivity()).buyBitcoinMe();\n+//            }\n+//        }).start();\n \n         return rootView;\n     }\ndiff --git a/app/src/main/java/com/platform/APIClient.java b/app/src/main/java/com/platform/APIClient.java\nindex 5be46cc20..6453856ee 100644\n--- a/app/src/main/java/com/platform/APIClient.java\n+++ b/app/src/main/java/com/platform/APIClient.java\n@@ -101,7 +101,8 @@ public class APIClient {\n     private static final String POST = "POST";\n \n     public static final String BUNDLES = "bundles";\n-    public static final String BREAD_BUY = "bread-buy";\n+//    public static final String BREAD_BUY = "bread-buy";\n+    public static final String BREAD_BUY = "bread-buy-staging";\n \n     public static String bundlesFileName = String.format("/%s", BUNDLES);\n     public static String bundleFileName = String.format("/%s/%s.tar", BUNDLES, BREAD_BUY);\ndiff --git a/app/src/main/java/com/platform/interfaces/Plugin.java b/app/src/main/java/com/platform/interfaces/Plugin.java\nnew file mode 100644\nindex 000000000..09c70f3ab\n--- /dev/null\n+++ b/app/src/main/java/com/platform/interfaces/Plugin.java\n@@ -0,0 +1,34 @@\n+package com.platform.interfaces;\n+\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\n+\n+/**\n+ * BreadWallet\n+ * <p/>\n+ * Created by Mihail Gutan on <mihail@breadwallet.com> 11/1/16.\n+ * Copyright (c) 2016 breadwallet LLC\n+ * <p/>\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the "Software"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ * <p/>\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ * <p/>\n+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+public interface Plugin {\n+    public static final String TAG = Plugin.class.getName();\n+\n+    public boolean handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response);\n+}\ndiff --git a/app/src/main/java/com/platform/middlewares/APIProxy.java b/app/src/main/java/com/platform/middlewares/APIProxy.java\nindex ce5c972c7..a0a29fdf5 100644\n--- a/app/src/main/java/com/platform/middlewares/APIProxy.java\n+++ b/app/src/main/java/com/platform/middlewares/APIProxy.java\n@@ -28,7 +28,6 @@ import okhttp3.ResponseBody;\n import static android.R.attr.path;\n import static com.breadwallet.R.string.request;\n \n-\n /**\n  * BreadWallet\n  * <p/>\n@@ -115,11 +114,9 @@ public class APIProxy implements Middleware {\n                 response.setContentLength(bodyBytes.length);\n                 response.getOutputStream().write(bodyBytes);\n                 baseRequest.setHandled(true);\n-\n             } catch (IOException e) {\n                 e.printStackTrace();\n             }\n-\n             return true;\n         }\n \ndiff --git a/app/src/main/java/com/platform/middlewares/HTTPRouter.java b/app/src/main/java/com/platform/middlewares/HTTPRouter.java\nindex 494e78aa1..f4226e2b2 100644\n--- a/app/src/main/java/com/platform/middlewares/HTTPRouter.java\n+++ b/app/src/main/java/com/platform/middlewares/HTTPRouter.java\n@@ -1,6 +1,10 @@\n package com.platform.middlewares;\n \n import com.platform.interfaces.Middleware;\n+import com.platform.interfaces.Plugin;\n+\n+import java.util.LinkedHashSet;\n+import java.util.Set;\n \n import javax.servlet.http.HttpServletRequest;\n import javax.servlet.http.HttpServletResponse;\n@@ -34,9 +38,23 @@ import okhttp3.Response;\n  */\n public class HTTPRouter implements Middleware {\n     public static final String TAG = HTTPRouter.class.getName();\n+    Set<Plugin> plugins;\n+\n+    public HTTPRouter() {\n+        plugins = new LinkedHashSet<>();\n+    }\n \n     @Override\n     public boolean handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) {\n+        boolean success = false;\n+        for (Plugin plugin : plugins) {\n+            success = plugin.handle(target, baseRequest, request, response);\n+            if(success) return true;\n+        }\n         return false;\n     }\n+\n+    public void appendPlugin(Plugin plugin) {\n+        plugins.add(plugin);\n+    }\n }\ndiff --git a/app/src/main/java/com/platform/middlewares/plugins/KVStorePlugin.java b/app/src/main/java/com/platform/middlewares/plugins/KVStorePlugin.java\nnew file mode 100644\nindex 000000000..b56ffcc1b\n--- /dev/null\n+++ b/app/src/main/java/com/platform/middlewares/plugins/KVStorePlugin.java\n@@ -0,0 +1,31 @@\n+package com.platform.middlewares.plugins;\n+\n+import com.platform.interfaces.Plugin;\n+\n+/**\n+ * BreadWallet\n+ * <p/>\n+ * Created by Mihail Gutan on <mihail@breadwallet.com> 11/1/16.\n+ * Copyright (c) 2016 breadwallet LLC\n+ * <p/>\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the "Software"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ * <p/>\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ * <p/>\n+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+public class KVStorePlugin implements Plugin{\n+    public static final String TAG = KVStorePlugin.class.getName();\n+}\n', 'commit_subject': 'plugins for the HttpRouter', 'repo_name': 'breadwallet/breadwallet-android', 'committer': {'name': 'Gutyn', 'email': '890e5834d074cef10299f00169972c87a1ea7f5a@gmail.com', 'time_sec': '1478043446', 'tz_offset': '-420', 'date': {'seconds': '1478043446'}}, 'commit_tree': 'a4c54427c2aa925d2655960e09e9f1b67f3e05dc', 'commit_message': 'plugins for the HttpRouter\n', 'language_name': 'Kotlin', 'license': 'mit', 'hunks': '@@ -0,0 +1,31 @@\n+package com.platform.middlewares.plugins;\n+\n+import com.platform.interfaces.Plugin;\n+\n+/**\n+ * BreadWallet\n+ * <p/>\n+ * Created by Mihail Gutan on <mihail@breadwallet.com> 11/1/16.\n+ * Copyright (c) 2016 breadwallet LLC\n+ * <p/>\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the "Software"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ * <p/>\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ * <p/>\n+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+public class KVStorePlugin implements Plugin{\n+    public static final String TAG = KVStorePlugin.class.getName();\n+}\n', 'addition_count': 31, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/app/src/main/java/com/platform/middlewares/plugins/KVStorePlugin.java', 'file_extension': '.java', 'before_file': 'ADDFILE', 'message': 'plugins for the HttpRouter\n', 'author_name': 'Gutyn', 'lang': 'java'}