MCPcopy Index your code
hub / github.com/zalando/skipper / runFunc

Method runFunc

script/script.go:294–321  ·  view source on GitHub ↗
(name string, f filters.FilterContext)

Source from the content-addressed store, hash-verified

292}
293
294func (s *script) runFunc(name string, f filters.FilterContext) {
295 L, err := s.getState()
296 if err != nil {
297 log.Errorf("Error obtaining lua environment: %v", err)
298 return
299 }
300 defer s.putState(L)
301
302 pt := L.CreateTable(len(s.routeParams), len(s.routeParams))
303 for i, p := range s.routeParams {
304 k, v, _ := strings.Cut(p, "=")
305 pt.RawSetString(k, lua.LString(v))
306 pt.RawSetInt(i+1, lua.LString(p))
307 }
308
309 err = L.CallByParam(
310 lua.P{
311 Fn: L.GetGlobal(name),
312 NRet: 0,
313 Protect: true,
314 },
315 s.filterContextAsLuaTable(L, f),
316 pt,
317 )
318 if err != nil {
319 log.Errorf("Error calling %s from %s: %v", name, s.source, err)
320 }
321}
322
323func (s *script) filterContextAsLuaTable(L *lua.LState, f filters.FilterContext) *lua.LTable {
324 // this will be passed as parameter to the lua functions

Callers 2

RequestMethod · 0.95
ResponseMethod · 0.95

Calls 4

getStateMethod · 0.95
putStateMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected