(rules ExecutionRules, begin, done, main *context.Handlers)
| 23 | } |
| 24 | |
| 25 | func applyExecutionRules(rules ExecutionRules, begin, done, main *context.Handlers) { |
| 26 | if !rules.Begin.Force && !rules.Done.Force && !rules.Main.Force { |
| 27 | return // do not proceed and spend build-time here if nothing changed. |
| 28 | } |
| 29 | |
| 30 | beginOK := rules.Begin.apply(begin) |
| 31 | mainOK := rules.Main.apply(main) |
| 32 | doneOK := rules.Done.apply(done) |
| 33 | |
| 34 | if !mainOK { |
| 35 | mainCp := (*main)[0:] |
| 36 | |
| 37 | lastIdx := len(mainCp) - 1 |
| 38 | |
| 39 | if beginOK { |
| 40 | if len(mainCp) > 1 { |
| 41 | mainCpFirstButNotLast := make(context.Handlers, lastIdx) |
| 42 | copy(mainCpFirstButNotLast, mainCp[:lastIdx]) |
| 43 | |
| 44 | for i, h := range mainCpFirstButNotLast { |
| 45 | (*main)[i] = rules.Begin.buildHandler(h) |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | if doneOK { |
| 51 | latestMainHandler := mainCp[lastIdx] |
| 52 | (*main)[lastIdx] = rules.Done.buildHandler(latestMainHandler) |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // ExecutionOptions is a set of default behaviors that can be changed in order to customize the execution flow of the routes' handlers with ease. |
| 58 | // |
no test coverage detected
searching dependent graphs…