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

Function runFilter

script/script_test.go:932–972  ·  view source on GitHub ↗
(opts LuaOptions, test *testContext)

Source from the content-addressed store, hash-verified

930}
931
932func runFilter(opts LuaOptions, test *testContext) (filters.FilterContext, error) {
933 scr, err := newFilter(opts, test.script, test.params...)
934 if err != nil {
935 return nil, err
936 }
937 url := "http://www.example.com/foo/bar"
938 if test.url != "" {
939 url = test.url
940 }
941 req, _ := http.NewRequest("GET", url, nil)
942 if test.requestHeader != nil {
943 req.Header = test.requestHeader.Clone()
944 }
945 fc := &filtertest.Context{
946 FParams: test.pathParams,
947 FStateBag: make(map[string]interface{}),
948 FRequest: req,
949 FOutgoingHost: "www.example.com",
950 }
951 scr.Request(fc)
952
953 body := "Hello world"
954 fc.FResponse = &http.Response{
955 Status: "200 OK",
956 StatusCode: 200,
957 Proto: "HTTP/1.1",
958 ProtoMajor: 1,
959 ProtoMinor: 1,
960 Body: io.NopCloser(bytes.NewBufferString(body)),
961 ContentLength: int64(len(body)),
962 Request: req,
963 Header: make(http.Header),
964 }
965 if test.responseHeader != nil {
966 fc.Response().Header = test.responseHeader.Clone()
967 }
968
969 scr.Response(fc)
970
971 return fc, nil
972}
973
974func runExample(ctx *testContext) {
975 runExampleWithOptions(LuaOptions{}, ctx)

Callers 3

TestScriptFunction · 0.85
TestSleepFunction · 0.85
runExampleWithOptionsFunction · 0.85

Calls 4

ResponseMethod · 0.95
newFilterFunction · 0.85
RequestMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…