Quellcode durchsuchen

新增检测负载均衡器健康接口

guanhailong vor 2 Jahren
Ursprung
Commit
16e2986d8e
1 geänderte Dateien mit 30 neuen und 0 gelöschten Zeilen
  1. 30 0
      Controller/InitController.py

+ 30 - 0
Controller/InitController.py

@@ -0,0 +1,30 @@
+# @Author    : Rocky
+# @File      : InitController.py
+# @Time      : 2023/4/11 17:26
+from django.http import HttpResponse
+import logging
+from django.views import View
+
+from Object.ResponseObject import ResponseObject
+
+
+class InitView(View):
+
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.GET, operation)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.POST, operation)
+
+    def validation(self, request_dict, operation):
+        if operation == 'health-check':  # 负载均衡器健康检测接口
+            return self.health_check(request_dict)
+
+    @staticmethod
+    def health_check(request_dict):
+        response = ResponseObject()
+        return response.json(0)