CreateFilter creates the lua script filter.
(config []interface{})
| 84 | |
| 85 | // CreateFilter creates the lua script filter. |
| 86 | func (ls *luaScript) CreateFilter(config []interface{}) (filters.Filter, error) { |
| 87 | if len(ls.sources) == 0 { |
| 88 | return nil, errLuaSourcesDisabled |
| 89 | } |
| 90 | if len(config) == 0 { |
| 91 | return nil, filters.ErrInvalidFilterParameters |
| 92 | } |
| 93 | src, ok := config[0].(string) |
| 94 | if !ok { |
| 95 | return nil, filters.ErrInvalidFilterParameters |
| 96 | } |
| 97 | var params []string |
| 98 | for _, p := range config[1:] { |
| 99 | ps, ok := p.(string) |
| 100 | if !ok { |
| 101 | return nil, filters.ErrInvalidFilterParameters |
| 102 | } |
| 103 | params = append(params, ps) |
| 104 | } |
| 105 | |
| 106 | s := &script{source: src, routeParams: params} |
| 107 | if err := s.initScript(ls.modules, ls.sources); err != nil { |
| 108 | return nil, err |
| 109 | } |
| 110 | return s, nil |
| 111 | } |
| 112 | |
| 113 | type script struct { |
| 114 | source string |
nothing calls this directly
no test coverage detected