feat: temporary support for creating collection configurations api
This commit is contained in:
parent
24887cce83
commit
070d1947e8
|
@ -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")
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue