diff options
Diffstat (limited to 'directives_generate.go')
-rw-r--r-- | directives_generate.go | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/directives_generate.go b/directives_generate.go index ccee3a0f3..62e69e165 100644 --- a/directives_generate.go +++ b/directives_generate.go @@ -25,22 +25,23 @@ func main() { scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() - if !strings.HasPrefix(line, `//`) && !strings.HasPrefix(line, "#") { - items := strings.Split(line, ":") - if len(items) == 3 { - if priority, err := strconv.Atoi(items[0]); err == nil { - md[priority] = items[1] - } - - if items[2] != "" { - if strings.Contains(items[2], "/") { - mi[items[1]] = items[2] - } else { - mi[items[1]] = middlewarePath + items[2] - } - } - - } + if strings.HasPrefix(line, "#") { + continue + } + + items := strings.Split(line, ":") + if len(items) != 3 { + // ignore + continue + } + priority, err := strconv.Atoi(items[0]) + fatalIfErr(err) + + md[priority] = items[1] + mi[items[1]] = middlewarePath + items[2] // Default, unless overriden by 3rd arg + + if strings.Contains(items[2], "/") { // External package has been given + mi[items[1]] = items[2] } } |