You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sh...@apache.org on 2021/08/03 02:35:38 UTC

[apisix-python-plugin-runner] 01/04: feat: add http method module for runner.

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

shuaijinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-python-plugin-runner.git

commit 2ee3dd4fe529458dfe7a70d231c218f9a58cfff3
Author: Janko <sh...@gmail.com>
AuthorDate: Tue Aug 3 10:20:57 2021 +0800

    feat: add http method module for runner.
---
 src/runner/http/method.py | 77 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/src/runner/http/method.py b/src/runner/http/method.py
new file mode 100644
index 0000000..32f0af3
--- /dev/null
+++ b/src/runner/http/method.py
@@ -0,0 +1,77 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+from a6pluginproto import Method as A6Method
+
+A6MethodGET = "GET"
+A6MethodHEAD = "HEAD"
+A6MethodPOST = "POST"
+A6MethodPUT = "PUT"
+A6MethodDELETE = "DELETE"
+A6MethodMKCOL = "MKCOL"
+A6MethodCOPY = "COPY"
+A6MethodMOVE = "MOVE"
+A6MethodOPTIONS = "OPTIONS"
+A6MethodPROPFIND = "PROPFIND"
+A6MethodPROPPATCH = "PROPPATCH"
+A6MethodLOCK = "LOCK"
+A6MethodUNLOCK = "UNLOCK"
+A6MethodPATCH = "PATCH"
+A6MethodTRACE = "TRACE"
+
+methodName = {
+    A6Method.Method.GET: A6MethodGET,
+    A6Method.Method.HEAD: A6MethodHEAD,
+    A6Method.Method.POST: A6MethodPOST,
+    A6Method.Method.PUT: A6MethodPUT,
+    A6Method.Method.DELETE: A6MethodDELETE,
+    A6Method.Method.MKCOL: A6MethodMKCOL,
+    A6Method.Method.COPY: A6MethodCOPY,
+    A6Method.Method.MOVE: A6MethodMOVE,
+    A6Method.Method.OPTIONS: A6MethodOPTIONS,
+    A6Method.Method.PROPFIND: A6MethodPROPFIND,
+    A6Method.Method.PROPPATCH: A6MethodPROPPATCH,
+    A6Method.Method.LOCK: A6MethodLOCK,
+    A6Method.Method.UNLOCK: A6MethodUNLOCK,
+    A6Method.Method.PATCH: A6MethodPATCH,
+    A6Method.Method.TRACE: A6MethodTRACE,
+}
+
+methodCode = {
+    A6MethodGET: A6Method.Method.GET,
+    A6MethodHEAD: A6Method.Method.HEAD,
+    A6MethodPOST: A6Method.Method.POST,
+    A6MethodPUT: A6Method.Method.PUT,
+    A6MethodDELETE: A6Method.Method.DELETE,
+    A6MethodMKCOL: A6Method.Method.MKCOL,
+    A6MethodCOPY: A6Method.Method.COPY,
+    A6MethodMOVE: A6Method.Method.MOVE,
+    A6MethodOPTIONS: A6Method.Method.OPTIONS,
+    A6MethodPROPFIND: A6Method.Method.PROPFIND,
+    A6MethodPROPPATCH: A6Method.Method.PROPPATCH,
+    A6MethodLOCK: A6Method.Method.LOCK,
+    A6MethodUNLOCK: A6Method.Method.UNLOCK,
+    A6MethodPATCH: A6Method.Method.PATCH,
+    A6MethodTRACE: A6Method.Method.TRACE,
+}
+
+
+def getNameByCode(code: int) -> str:
+    return methodName.get(code)
+
+
+def getCodeByName(name: str) -> int:
+    return methodCode.get(name)