Pull request: querylog: more opt

Updates 1273.

Squashed commit of the following:

commit 167c0b5acaab8a2676de2cea556c861dc0efbc72
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Apr 12 18:12:43 2021 +0300

    querylog: imp naming

commit 5010ad113e46335011a721cbcc9fc9b1fc623722
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Apr 12 17:53:41 2021 +0300

    querylog: more opt
This commit is contained in:
Ainar Garipov
2021-04-12 18:22:11 +03:00
parent 279350e4a3
commit 7c6557b05e
9 changed files with 209 additions and 80 deletions

View File

@@ -126,16 +126,16 @@ func getDoubleQuotesEnclosedValue(s *string) bool {
return false
}
// parseSearchCriteria - parses "searchCriteria" from the specified query parameter
func (l *queryLog) parseSearchCriteria(q url.Values, name string, ct criteriaType) (bool, searchCriteria, error) {
// parseSearchCriterion parses a search criterion from the query parameter.
func (l *queryLog) parseSearchCriterion(q url.Values, name string, ct criterionType) (bool, searchCriterion, error) {
val := q.Get(name)
if len(val) == 0 {
return false, searchCriteria{}, nil
return false, searchCriterion{}, nil
}
c := searchCriteria{
criteriaType: ct,
value: val,
c := searchCriterion{
criterionType: ct,
value: val,
}
if getDoubleQuotesEnclosedValue(&c.value) {
c.strict = true
@@ -175,15 +175,15 @@ func (l *queryLog) parseSearchParams(r *http.Request) (p *searchParams, err erro
p.maxFileScanEntries = 0
}
paramNames := map[string]criteriaType{
paramNames := map[string]criterionType{
"search": ctDomainOrClient,
"response_status": ctFilteringStatus,
}
for k, v := range paramNames {
var ok bool
var c searchCriteria
ok, c, err = l.parseSearchCriteria(q, k, v)
var c searchCriterion
ok, c, err = l.parseSearchCriterion(q, k, v)
if err != nil {
return nil, err
}