From b02c16a0461e8672ff9e2773d161862e72b6847c Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 7 Nov 2018 12:14:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.xml | 2 +- .../web/request/DemoRequestHandlerBridge.java | 6 ++-- .../demo/web/request/DemoURLAliasBridge.java | 3 +- .../request/handler/PrivateHttpHandler.java | 34 +++++++++++++++++++ ...ttpHandler.java => PublicHttpHandler.java} | 4 +-- 5 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/fr/plugin/demo/web/request/handler/PrivateHttpHandler.java rename src/main/java/com/fr/plugin/demo/web/request/handler/{DemoHttpHandler.java => PublicHttpHandler.java} (89%) diff --git a/plugin.xml b/plugin.xml index b5c3795..0775e61 100644 --- a/plugin.xml +++ b/plugin.xml @@ -15,5 +15,5 @@ - + \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/demo/web/request/DemoRequestHandlerBridge.java b/src/main/java/com/fr/plugin/demo/web/request/DemoRequestHandlerBridge.java index 75e1fef..6336e35 100644 --- a/src/main/java/com/fr/plugin/demo/web/request/DemoRequestHandlerBridge.java +++ b/src/main/java/com/fr/plugin/demo/web/request/DemoRequestHandlerBridge.java @@ -2,14 +2,16 @@ package com.fr.plugin.demo.web.request; import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; import com.fr.decision.fun.impl.BaseHttpHandler; -import com.fr.plugin.demo.web.request.handler.DemoHttpHandler; +import com.fr.plugin.demo.web.request.handler.PrivateHttpHandler; +import com.fr.plugin.demo.web.request.handler.PublicHttpHandler; public class DemoRequestHandlerBridge extends AbstractHttpHandlerProvider { @Override public BaseHttpHandler[] registerHandlers() { return new BaseHttpHandler[]{ - new DemoHttpHandler() + new PublicHttpHandler(), + new PrivateHttpHandler() }; } } diff --git a/src/main/java/com/fr/plugin/demo/web/request/DemoURLAliasBridge.java b/src/main/java/com/fr/plugin/demo/web/request/DemoURLAliasBridge.java index 77621e3..7e84413 100644 --- a/src/main/java/com/fr/plugin/demo/web/request/DemoURLAliasBridge.java +++ b/src/main/java/com/fr/plugin/demo/web/request/DemoURLAliasBridge.java @@ -8,7 +8,8 @@ public class DemoURLAliasBridge extends AbstractURLAliasProvider { @Override public URLAlias[] registerAlias() { return new URLAlias[] { - URLAliasFactory.createPluginAlias("/demo/text", "/demo/simple", true) + URLAliasFactory.createPluginAlias("/demo/simple/text", "/demo/text", true), + URLAliasFactory.createPluginAlias("/demo/simple/abc", "/demo/abc", false) }; } } diff --git a/src/main/java/com/fr/plugin/demo/web/request/handler/PrivateHttpHandler.java b/src/main/java/com/fr/plugin/demo/web/request/handler/PrivateHttpHandler.java new file mode 100644 index 0000000..e89d0a9 --- /dev/null +++ b/src/main/java/com/fr/plugin/demo/web/request/handler/PrivateHttpHandler.java @@ -0,0 +1,34 @@ +package com.fr.plugin.demo.web.request.handler; + +import com.fr.decision.fun.impl.BaseHttpHandler; +import com.fr.third.springframework.web.bind.annotation.RequestMethod; +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; + +public class PrivateHttpHandler extends BaseHttpHandler { + @Override + public RequestMethod getMethod() { + return RequestMethod.GET; + } + + @Override + public String getPath() { + return "/demo/abc"; + } + + @Override + public boolean isPublic() { + return false; + } + + @Override + public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { + PrintWriter writer = WebUtils.createPrintWriter(res); + writer.println("Hello, I am a private request."); + writer.flush(); + writer.close(); + } +} diff --git a/src/main/java/com/fr/plugin/demo/web/request/handler/DemoHttpHandler.java b/src/main/java/com/fr/plugin/demo/web/request/handler/PublicHttpHandler.java similarity index 89% rename from src/main/java/com/fr/plugin/demo/web/request/handler/DemoHttpHandler.java rename to src/main/java/com/fr/plugin/demo/web/request/handler/PublicHttpHandler.java index 315cb3a..909c1cb 100644 --- a/src/main/java/com/fr/plugin/demo/web/request/handler/DemoHttpHandler.java +++ b/src/main/java/com/fr/plugin/demo/web/request/handler/PublicHttpHandler.java @@ -12,7 +12,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; @EnableMetrics -public class DemoHttpHandler extends BaseHttpHandler { +public class PublicHttpHandler extends BaseHttpHandler { @Override public RequestMethod getMethod() { @@ -33,7 +33,7 @@ public class DemoHttpHandler extends BaseHttpHandler { @Focus(id = "com.fr.plugin.demo.web.request", text = "", source = Original.PLUGIN) public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { PrintWriter writer = WebUtils.createPrintWriter(res); - writer.println("Hello, I am a test."); + writer.println("Hello, I am a public request."); writer.flush(); writer.close(); }