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

Method call

context/context_func.go:122–174  ·  view source on GitHub ↗
(ctx *Context, args ...interface{})

Source from the content-addressed store, hash-verified

120}
121
122func (f *Func) call(ctx *Context, args ...interface{}) ([]reflect.Value, error) {
123 f.once.Do(f.buildMeta)
124 meta := f.Meta
125
126 if meta.Handler != nil {
127 meta.Handler(ctx)
128 return nil, nil
129 }
130
131 if meta.HandlerWithErr != nil {
132 return nil, meta.HandlerWithErr(ctx)
133 }
134
135 if meta.RawFunc != nil {
136 meta.RawFunc()
137 return nil, nil
138 }
139
140 if meta.RawFuncWithErr != nil {
141 return nil, meta.RawFuncWithErr()
142 }
143
144 if meta.RawFuncArgs != nil {
145 meta.RawFuncArgs(args...)
146 return nil, nil
147 }
148
149 if meta.RawFuncArgsWithErr != nil {
150 return nil, meta.RawFuncArgsWithErr(args...)
151 }
152
153 inputs := make([]reflect.Value, 0, f.Meta.ExpectedArgumentsLength)
154 inputs = append(inputs, f.Meta.PersistenceInputs...)
155 if f.Meta.AcceptsContext {
156 inputs = append(inputs, reflect.ValueOf(ctx))
157 }
158
159 for _, arg := range args {
160 if in, ok := arg.(reflect.Value); ok {
161 inputs = append(inputs, in)
162 } else {
163 inputs = append(inputs, reflect.ValueOf(arg))
164 }
165 }
166
167 // keep it here, the inptus may contain the context.
168 if f.Meta.ExpectedArgumentsLength != len(inputs) {
169 return nil, ErrInvalidArgs
170 }
171
172 outputs := f.Meta.Value.Call(inputs)
173 return outputs, getError(outputs)
174}
175
176var contextType = reflect.TypeOf((*Context)(nil))
177

Callers 11

dropzone.jsFile · 0.80
extend1Function · 0.80
DropzoneFunction · 0.80
fFunction · 0.80
tFunction · 0.80
lFunction · 0.80
bundle.jsFile · 0.80
iFunction · 0.80
nFunction · 0.80
uFunction · 0.80
CallFuncMethod · 0.80

Calls 3

getErrorFunction · 0.85
DoMethod · 0.45
HandlerMethod · 0.45

Tested by

no test coverage detected