summaryrefslogtreecommitdiff
path: root/router
diff options
context:
space:
mode:
Diffstat (limited to 'router')
-rw-r--r--router/comm_endpoint.go3
-rw-r--r--router/router.go7
-rw-r--r--router/rule_endpoint.go30
3 files changed, 37 insertions, 3 deletions
diff --git a/router/comm_endpoint.go b/router/comm_endpoint.go
index 1054b5f..cc43419 100644
--- a/router/comm_endpoint.go
+++ b/router/comm_endpoint.go
@@ -1,11 +1,12 @@
/*
* @Author: EnderByEndera
* @Date: 2021-01-16 08:14:22
- * @LastEditTime: 2021-01-16 08:16:11
+ * @LastEditTime: 2021-02-01 06:27:20
* @LastEditors: Please set LastEditors
* @Description: comm_endpoint.go has the function for all the commands' endpoint
* @FilePath: /commdetection/router/comm_endpoint.go
*/
+
package router
import (
diff --git a/router/router.go b/router/router.go
index 8c08a7b..583b10f 100644
--- a/router/router.go
+++ b/router/router.go
@@ -1,7 +1,7 @@
/*
* @Author: EnderByEndera
* @Date: 2020-12-23 13:17:08
- * @LastEditTime: 2021-01-19 12:06:31
+ * @LastEditTime: 2021-02-01 06:27:01
* @LastEditors: Please set LastEditors
* @Description: router.go defines gin.Engine and its router
* @FilePath: /commdetection/route/router.go
@@ -96,6 +96,11 @@ func manageRouter() {
pathr.POST("/set", setPathrulesEndpoint)
pathr.GET("/get", getPathrulesEndpoint)
}
+ usiter := router.Group("/websiterules")
+ {
+ usiter.POST("/set", setWebsiteRuleEndpoint)
+ usiter.GET("/get", getWebsiteRuleEndpoint)
+ }
rsr := router.Group("/rules")
{
rsr.POST("/set", setEvaluationRulesEndpoint)
diff --git a/router/rule_endpoint.go b/router/rule_endpoint.go
index d8bc59f..15df06f 100644
--- a/router/rule_endpoint.go
+++ b/router/rule_endpoint.go
@@ -1,7 +1,7 @@
/*
* @Author: EnderByEndera
* @Date: 2021-01-16 08:12:49
- * @LastEditTime: 2021-01-16 08:16:53
+ * @LastEditTime: 2021-02-01 06:26:33
* @LastEditors: Please set LastEditors
* @Description: rule_endpoint has the function for all the command rules' endpoint, including getter and setter
* @FilePath: /commdetection/router/rule_endpoint.go
@@ -135,3 +135,31 @@ func setEvaluationRulesEndpoint(c *gin.Context) {
"message": "ok",
})
}
+
+func getWebsiteRuleEndpoint(c *gin.Context) {
+ ussites, err := model.UnMarshalUnsensitiveWebsiteSetting()
+ if err != nil {
+ handleErr(c, err)
+ return
+ }
+ logger.Debugln("Start to send spaths to the front end")
+ c.JSON(http.StatusOK, gin.H{
+ "message": "ok",
+ "ussites": ussites,
+ })
+}
+
+func setWebsiteRuleEndpoint(c *gin.Context) {
+ ussites := model.Ussites{}
+ if err := c.ShouldBind(&ussites); err != nil {
+ handleErr(c, err)
+ return
+ }
+ if err := model.MarshalUnsensitiveWebsiteSetting(ussites); err != nil {
+ handleErr(c, err)
+ return
+ }
+ c.JSON(http.StatusOK, gin.H{
+ "message": "ok",
+ })
+}