MCPcopy Create free account
hub / github.com/kataras/iris / applyExecutionRules

Function applyExecutionRules

core/router/handler_execution_rules.go:25–55  ·  view source on GitHub ↗
(rules ExecutionRules, begin, done, main *context.Handlers)

Source from the content-addressed store, hash-verified

23}
24
25func 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//

Callers 1

createRoutesMethod · 0.85

Calls 2

applyMethod · 0.80
buildHandlerMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…