mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-14 14:23:33 +01:00
- Replace template syntax ({{ .Request.Method }}) with $-prefixed variables ($req_method)
- Implement custom variable parser with static ($req_method, $status_code) and dynamic ($header(), $arg(), $form()) variables
- Replace templateOrStr interface with templateString struct and ExpandVars methods
- Add parser improvements for reliable quote handling
- Add new error types: ErrUnterminatedParenthesis, ErrUnexpectedVar, ErrExpectOneOrTwoArgs
- Update all tests and help text to use new variable syntax
- Add comprehensive unit and benchmark tests for variable expansion
35 lines
1.5 KiB
Go
35 lines
1.5 KiB
Go
package rules
|
|
|
|
import (
|
|
gperr "github.com/yusing/goutils/errs"
|
|
)
|
|
|
|
var (
|
|
ErrUnterminatedQuotes = gperr.New("unterminated quotes")
|
|
ErrUnterminatedBrackets = gperr.New("unterminated brackets")
|
|
ErrUnterminatedParenthesis = gperr.New("unterminated parenthesis")
|
|
ErrUnterminatedEnvVar = gperr.New("unterminated env var")
|
|
ErrUnknownDirective = gperr.New("unknown directive")
|
|
ErrUnknownModField = gperr.New("unknown field")
|
|
ErrEnvVarNotFound = gperr.New("env variable not found")
|
|
ErrInvalidArguments = gperr.New("invalid arguments")
|
|
ErrInvalidOnTarget = gperr.New("invalid `rule.on` target")
|
|
ErrInvalidCommandSequence = gperr.New("invalid command sequence")
|
|
|
|
// vars errors
|
|
ErrNoArgProvided = gperr.New("no argument provided")
|
|
ErrUnexpectedVar = gperr.New("unexpected variable")
|
|
ErrUnexpectedQuote = gperr.New("unexpected quote")
|
|
|
|
ErrExpectNoArg = gperr.Wrap(ErrInvalidArguments, "expect no arg")
|
|
ErrExpectOneArg = gperr.Wrap(ErrInvalidArguments, "expect 1 arg")
|
|
ErrExpectOneOrTwoArgs = gperr.Wrap(ErrInvalidArguments, "expect 1 or 2 args")
|
|
ErrExpectTwoArgs = gperr.Wrap(ErrInvalidArguments, "expect 2 args")
|
|
ErrExpectTwoOrThreeArgs = gperr.Wrap(ErrInvalidArguments, "expect 2 or 3 args")
|
|
ErrExpectThreeArgs = gperr.Wrap(ErrInvalidArguments, "expect 3 args")
|
|
ErrExpectFourArgs = gperr.Wrap(ErrInvalidArguments, "expect 4 args")
|
|
ErrExpectKVOptionalV = gperr.Wrap(ErrInvalidArguments, "expect 'key' or 'key value'")
|
|
|
|
errTerminated = gperr.New("terminated")
|
|
)
|