(f filters.FilterContext)
| 460 | } |
| 461 | |
| 462 | func getRequestValue(f filters.FilterContext) func(*lua.LState) int { |
| 463 | var header, cookie, url_query *lua.LTable |
| 464 | return func(s *lua.LState) int { |
| 465 | key := s.ToString(-1) |
| 466 | var ret lua.LValue |
| 467 | switch key { |
| 468 | case "header": |
| 469 | if header == nil { |
| 470 | header = s.CreateTable(0, 2) |
| 471 | header.RawSetString("add", s.NewFunction(addRequestHeader(f))) |
| 472 | header.RawSetString("values", s.NewFunction(requestHeaderValues(f))) |
| 473 | |
| 474 | mt := s.CreateTable(0, 3) |
| 475 | mt.RawSetString("__index", s.NewFunction(getRequestHeader(f))) |
| 476 | mt.RawSetString("__newindex", s.NewFunction(setRequestHeader(f))) |
| 477 | mt.RawSetString("__call", s.NewFunction(iterateRequestHeader(f))) |
| 478 | s.SetMetatable(header, mt) |
| 479 | } |
| 480 | ret = header |
| 481 | case "cookie": |
| 482 | if cookie == nil { |
| 483 | cookie = s.CreateTable(0, 0) |
| 484 | mt := s.CreateTable(0, 3) |
| 485 | mt.RawSetString("__index", s.NewFunction(getRequestCookie(f))) |
| 486 | mt.RawSetString("__newindex", s.NewFunction(unsupported("setting cookie is not supported"))) |
| 487 | mt.RawSetString("__call", s.NewFunction(iterateRequestCookie(f))) |
| 488 | s.SetMetatable(cookie, mt) |
| 489 | } |
| 490 | ret = cookie |
| 491 | case "outgoing_host": |
| 492 | ret = lua.LString(f.OutgoingHost()) |
| 493 | case "backend_url": |
| 494 | ret = lua.LString(f.BackendUrl()) |
| 495 | case "host": |
| 496 | ret = lua.LString(f.Request().Host) |
| 497 | case "remote_addr": |
| 498 | ret = lua.LString(f.Request().RemoteAddr) |
| 499 | case "content_length": |
| 500 | ret = lua.LNumber(f.Request().ContentLength) |
| 501 | case "proto": |
| 502 | ret = lua.LString(f.Request().Proto) |
| 503 | case "method": |
| 504 | ret = lua.LString(f.Request().Method) |
| 505 | case "url": |
| 506 | ret = lua.LString(f.Request().URL.String()) |
| 507 | case "url_path": |
| 508 | ret = lua.LString(f.Request().URL.Path) |
| 509 | case "url_query": |
| 510 | if url_query == nil { |
| 511 | url_query = s.CreateTable(0, 0) |
| 512 | mt := s.CreateTable(0, 3) |
| 513 | mt.RawSetString("__index", s.NewFunction(getRequestURLQuery(f))) |
| 514 | mt.RawSetString("__newindex", s.NewFunction(setRequestURLQuery(f))) |
| 515 | mt.RawSetString("__call", s.NewFunction(iterateRequestURLQuery(f))) |
| 516 | s.SetMetatable(url_query, mt) |
| 517 | } |
| 518 | ret = url_query |
| 519 | case "url_raw_query": |
no test coverage detected
searching dependent graphs…