github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/checkpoints/request_uri.go (about)

     1  package checkpoints
     2  
     3  import (
     4  	"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
     5  	"github.com/TeaOSLab/EdgeNode/internal/waf/utils"
     6  	"github.com/iwind/TeaGo/maps"
     7  )
     8  
     9  type RequestURICheckpoint struct {
    10  	Checkpoint
    11  }
    12  
    13  func (this *RequestURICheckpoint) RequestValue(req requests.Request, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) {
    14  	if len(req.WAFRaw().RequestURI) > 0 {
    15  		value = req.WAFRaw().RequestURI
    16  	} else if req.WAFRaw().URL != nil {
    17  		value = req.WAFRaw().URL.RequestURI()
    18  	}
    19  	return
    20  }
    21  
    22  func (this *RequestURICheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) {
    23  	if this.IsRequest() {
    24  		return this.RequestValue(req, param, options, ruleId)
    25  	}
    26  	return
    27  }
    28  
    29  func (this *RequestURICheckpoint) CacheLife() utils.CacheLife {
    30  	return utils.CacheShortLife
    31  }