func IfMatcherKeyword(c *casket.Controller) bool {
	if c.Val() == "if" || c.Val() == "if_op" {
		c.RemainingArgs()
		return true
	}
	return false
}
IfMatcherKeyword checks if the next value in the dispenser is a keyword for 'if' config block.
If true, remaining arguments in the dispenser are cleared to keep the dispenser valid for use.
package httpserver
import (
	"fmt"
	"net/http"
	"regexp"
	"strings"
	"github.com/tmpim/casket"
)
func SetupIfMatcher(controller *casket.Controller) (RequestMatcher, error) {
	var c = controller.Dispenser  
	var matcher IfMatcher
	for c.NextBlock() {
		switch c.Val() {
		case "if":
			args1 := c.RemainingArgs()
			if len(args1) != 3 {
				return matcher, c.ArgErr()
			}
			ifc, err := newIfCond(args1[0], args1[1], args1[2])
			if err != nil {
				return matcher, err
			}
			matcher.ifs = append(matcher.ifs, ifc)
			matcher.Enabled = true
		case "if_op":
			if !c.NextArg() {
				return matcher, c.ArgErr()
			}
			switch c.Val() {
			case "and":
				matcher.isOr = false
			case "or":
				matcher.isOr = true
			default:
				return matcher, c.ArgErr()
			}
		}
	}
	return matcher, nil
}
const (
	isOp         = "is"
	notOp        = "not"
	hasOp        = "has"
	startsWithOp = "starts_with"
	endsWithOp   = "ends_with"
	matchOp      = "match"
)
type ifFunc func(a, b string) bool
type ifCond struct {
	a   string
	op  string
	b   string
	neg bool
	rex *regexp.Regexp
	f   ifFunc
}
func newIfCond(a, op, b string) (ifCond, error) {
	i := ifCond{a: a, op: op, b: b}
	if strings.HasPrefix(op, "not_") {
		i.neg = true
		i.op = op[4:]
	}
	switch i.op {
	case isOp:
		i.f = i.isFunc
	case notOp:
		i.f = i.notFunc
	case hasOp:
		i.f = strings.Contains
	case startsWithOp:
		i.f = strings.HasPrefix
	case endsWithOp:
		i.f = strings.HasSuffix
	case matchOp:
		var err error
		if i.rex, err = regexp.Compile(i.b); err != nil {
			return ifCond{}, fmt.Errorf("Invalid regular expression: '%s', %v", i.b, err)
		}
		i.f = i.matchFunc
	default:
		return ifCond{}, fmt.Errorf("Invalid operator %v", i.op)
	}
	return i, nil
}
func (i ifCond) isFunc(a, b string) bool {
	return a == b
}
func (i ifCond) notFunc(a, b string) bool {
	return a != b
}
func (i ifCond) matchFunc(a, b string) bool {
	return i.rex.MatchString(a)
}
func (i ifCond) True(r *http.Request) bool {
	if i.f != nil {
		a, b := i.a, i.b
		if r != nil {
			replacer := NewReplacer(r, nil, "")
			a = replacer.Replace(i.a)
			if i.op != matchOp {
				b = replacer.Replace(i.b)
			}
		}
		if i.neg {
			return !i.f(a, b)
		}
		return i.f(a, b)
	}
	return i.neg  
}
type IfMatcher struct {
	Enabled bool      
	ifs     []ifCond  
	isOr    bool      
}
func (m IfMatcher) Match(r *http.Request) bool {
	if m.isOr {
		return m.Or(r)
	}
	return m.And(r)
}
func (m IfMatcher) And(r *http.Request) bool {
	for _, i := range m.ifs {
		if !i.True(r) {
			return false
		}
	}
	return true
}
func (m IfMatcher) Or(r *http.Request) bool {
	for _, i := range m.ifs {
		if i.True(r) {
			return true
		}
	}
	return false
}