mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 17:28:31 +02:00
feat(rules): add post-request rules system with response manipulation (#160)
* Add comprehensive post-request rules support for response phase * Enable response body, status, and header manipulation via set commands * Refactor command handlers to support both request and response phases * Implement response modifier system for post-request template execution * Support response-based rule matching with status and header checks * Add comprehensive benchmarks for matcher performance * Refactor authentication and proxying commands for unified error handling * Support negated conditions with ! * Enhance error handling, error formatting and validation * Routes: add `rule_file` field with rule preset support * Environment variable substitution: now supports variables without `GODOXY_` prefix * new conditions: * `on resp_header <key> [<value>]` * `on status <status>` * new commands: * `require_auth` * `set resp_header <key> <template>` * `set resp_body <template>` * `set status <code>` * `log <level> <path> <template>` * `notify <level> <provider> <title_template> <body_template>`
This commit is contained in:
@@ -7,15 +7,21 @@ import (
|
||||
var (
|
||||
ErrUnterminatedQuotes = gperr.New("unterminated quotes")
|
||||
ErrUnterminatedBrackets = gperr.New("unterminated brackets")
|
||||
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")
|
||||
ErrInvalidSetTarget = gperr.New("invalid `rule.set` target")
|
||||
|
||||
ErrExpectNoArg = gperr.Wrap(ErrInvalidArguments, "expect no arg")
|
||||
ErrExpectOneArg = gperr.Wrap(ErrInvalidArguments, "expect 1 arg")
|
||||
ErrExpectTwoArgs = gperr.Wrap(ErrInvalidArguments, "expect 2 args")
|
||||
ErrExpectKVOptionalV = gperr.Wrap(ErrInvalidArguments, "expect 'key' or 'key value'")
|
||||
ErrExpectNoArg = gperr.Wrap(ErrInvalidArguments, "expect no arg")
|
||||
ErrExpectOneArg = gperr.Wrap(ErrInvalidArguments, "expect 1 arg")
|
||||
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")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user