MCPcopy
hub / github.com/zalando/skipper / setStateBag

Function setStateBag

script/script.go:629–649  ·  view source on GitHub ↗
(f filters.FilterContext)

Source from the content-addressed store, hash-verified

627}
628
629func setStateBag(f filters.FilterContext) func(*lua.LState) int {
630 return func(s *lua.LState) int {
631 fld := s.ToString(-2)
632 val := s.Get(-1)
633 var res interface{}
634 switch val.Type() {
635 case lua.LTString:
636 res = string(val.(lua.LString))
637 case lua.LTNumber:
638 res = float64(val.(lua.LNumber))
639 case lua.LTTable:
640 res = val // store *lua.LTable as is
641 default:
642 // TODO(sszuecs): https://github.com/zalando/skipper/issues/1487
643 // s.RaiseError("unsupported state bag value type %v, need a string or a number", val.Type())
644 return 0
645 }
646 f.StateBag()[fld] = res
647 return 0
648 }
649}
650
651func getRequestHeader(f filters.FilterContext) func(*lua.LState) int {
652 return func(s *lua.LState) int {

Callers 1

getContextValueFunction · 0.85

Calls 2

GetMethod · 0.65
StateBagMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…