1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 20:07:04 +00:00

Conversion once at macros and their functions, internal changes required

Former-commit-id: 7b778cccfb7c0e30ca5e8106017ada065993aba5
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-09-27 03:17:45 +03:00
parent dc3c38b189
commit d6d27b2605
11 changed files with 338 additions and 279 deletions

View File

@@ -1,6 +1,8 @@
package macro
import (
"reflect"
"github.com/kataras/iris/core/router/macro/interpreter/ast"
"github.com/kataras/iris/core/router/macro/interpreter/parser"
)
@@ -27,8 +29,8 @@ type TemplateParam struct {
Name string `json:"name"`
Index int `json:"index"`
ErrCode int `json:"errCode"`
TypeEvaluator EvaluatorFunc `json:"-"`
Funcs []EvaluatorFunc `json:"-"`
TypeEvaluator ParamEvaluator `json:"-"`
Funcs []reflect.Value `json:"-"`
}
// Parse takes a full route path and a macro map (macro map contains the macro types with their registered param functions)
@@ -74,7 +76,7 @@ func Parse(src string, macros Macros) (*Template, error) {
}
evalFn := tmplFn(paramfn.Args)
if evalFn == nil {
if evalFn.IsNil() || !evalFn.IsValid() || evalFn.Kind() != reflect.Func {
continue
}
tmplParam.Funcs = append(tmplParam.Funcs, evalFn)