mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-24 07:31:53 +08:00
Use golint to normalize the code (#1)
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
package rhttp
|
||||
|
||||
type Config struct {
|
||||
IpHeader string
|
||||
IpHeader string
|
||||
}
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ func compileTpl(c *gin.Context, tpl string) (compiled string) {
|
||||
if headerVarMatcher.FindString(tpl) != "" {
|
||||
compiled = headerVarMatcher.ReplaceAllString(compiled, c.GetHeader(headerVarMatcher.FindStringSubmatch(tpl)[1]))
|
||||
}
|
||||
return
|
||||
return compiled
|
||||
}
|
||||
|
||||
func (s *Server) Receive(c *gin.Context) {
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ type Record struct {
|
||||
Path string `form:"path" json:"path"`
|
||||
record.BaseRecord
|
||||
RawRequest string `json:"raw_request" notice:"-"`
|
||||
Rule Rule `gorm:"foreignKey:RuleName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" form:"-" json:"-" notice:"-"`
|
||||
Rule Rule `gorm:"foreignKey:RuleName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" form:"-" json:"-" notice:"-"`
|
||||
}
|
||||
|
||||
func (Record) TableName() string {
|
||||
@@ -42,7 +42,7 @@ func NewRecord(rule *Rule, flag, method, url, ip, area, raw string) (r *Record,
|
||||
Rule: *rule,
|
||||
}
|
||||
err = database.DB.Create(r).Error
|
||||
return
|
||||
return r, err
|
||||
}
|
||||
|
||||
func ListRecords(c *gin.Context) {
|
||||
|
||||
+4
-5
@@ -13,7 +13,7 @@ import (
|
||||
// Http rule struct
|
||||
type Rule struct {
|
||||
rule.BaseRule
|
||||
ResponseStatusCode string `gorm:"index;default:200;not null" form:"response_status_code" json:"response_status_code"`
|
||||
ResponseStatusCode string `gorm:"index;default:200;not null" form:"response_status_code" json:"response_status_code"`
|
||||
ResponseHeaders database.MapField `form:"response_headers" json:"response_headers"`
|
||||
ResponseBody string `gorm:"default:Hello RevSuit!" form:"response_body" json:"response_body"`
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func (Rule) TableName() string {
|
||||
}
|
||||
|
||||
// New http rule struct
|
||||
func NewRule(name, flagFormat, responseBody string, pushToClient, notice bool, responseStatus string, responseHeaders database.MapField, ) *Rule {
|
||||
func NewRule(name, flagFormat, responseBody string, pushToClient, notice bool, responseStatus string, responseHeaders database.MapField) *Rule {
|
||||
return &Rule{
|
||||
BaseRule: rule.BaseRule{
|
||||
Name: name,
|
||||
@@ -59,7 +59,7 @@ func (r *Rule) CreateOrUpdate() (err error) {
|
||||
}
|
||||
|
||||
err = GetServer().updateRules()
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete the http rule in database and ruleSet
|
||||
@@ -71,7 +71,7 @@ func (r *Rule) Delete() (err error) {
|
||||
}
|
||||
|
||||
err = GetServer().updateRules()
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
// List all http rules those satisfy the filter
|
||||
@@ -195,5 +195,4 @@ func DeleteRules(c *gin.Context) {
|
||||
"error": nil,
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user