diff --git a/http/router.go b/http/router.go index 284af216..a78f4370 100644 --- a/http/router.go +++ b/http/router.go @@ -173,6 +173,12 @@ func configRoutes(r *gin.Engine) { } + // for brower, expose location in nginx.conf + pagesV2 := r.Group("/api/n9e/v2", csrfMid) + { + pagesV2.POST("/collect-rules", login(), collectRulesAdd) + } + // for thirdparty, do not expose location in nginx.conf v1 := r.Group("/v1/n9e") { diff --git a/http/router_collect_rule.go b/http/router_collect_rule.go index ce8b014a..827c7a65 100644 --- a/http/router_collect_rule.go +++ b/http/router_collect_rule.go @@ -44,6 +44,32 @@ func collectRuleAdd(c *gin.Context) { renderMessage(c, cr.Add()) } +func collectRulesAdd(c *gin.Context) { + var forms []collectRuleForm + bind(c, &forms) + + me := loginUser(c).MustPerm("collect_rule_create") + + for _, f := range forms { + cr := models.CollectRule{ + ClasspathId: f.ClasspathId, + PrefixMatch: f.PrefixMatch, + Name: f.Name, + Note: f.Note, + Step: f.Step, + Type: f.Type, + Data: f.Data, + AppendTags: f.AppendTags, + CreateBy: me.Username, + UpdateBy: me.Username, + } + + dangerous(cr.Add()) + } + + renderMessage(c, nil) +} + func collectRulePut(c *gin.Context) { var f collectRuleForm bind(c, &f)