You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2023/01/22 10:25:06 UTC

[struts] 04/15: Adds new interface to allow action cooperate with HttpMethodInterceptor

This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch http-interceptor
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 68ded66f82aa0d1af9ba3b00abe9de782480fc9e
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Sat Apr 19 18:05:58 2014 +0200

    Adds new interface to allow action cooperate with HttpMethodInterceptor
---
 .../interceptor/httpmethod/HttpMethodAware.java    | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpMethodAware.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpMethodAware.java
new file mode 100644
index 000000000..cfdc7826c
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/HttpMethodAware.java
@@ -0,0 +1,30 @@
+package org.apache.struts2.interceptor.httpmethod;
+
+/**
+ * Action when implements this interface is notified about what method was used to perform request,
+ * it works in connection with {@link org.apache.struts2.interceptor.httpmethod.HttpMethodInterceptor}
+ *
+ * Another function of this interface is to return result which should be returned when action
+ * was called with wrong http method
+ *
+ * @since 2.3.18
+ */
+public interface HttpMethodAware {
+
+    /**
+     * Notifies action about http method used to perform request
+     *
+     * @param httpMethod {@link javax.servlet.http.HttpServletRequest#getMethod()} translated to enum
+     */
+    public void setMethod(HttpMethod httpMethod);
+
+    /**
+     * Action name to use when action was requested with wrong http method
+     * can return null and then default result name will be used instead defined
+     * in {@link org.apache.struts2.interceptor.httpmethod.HttpMethodInterceptor}
+     *
+     * @return result name or null
+     */
+    public String getBadRequestResultName();
+
+}