| 61 | } |
| 62 | |
| 63 | static int |
| 64 | ts_lua_http_intercept(lua_State *L) |
| 65 | { |
| 66 | TSCont contp; |
| 67 | int type, n; |
| 68 | ts_lua_http_ctx *http_ctx; |
| 69 | ts_lua_http_intercept_ctx *ictx; |
| 70 | |
| 71 | GET_HTTP_CONTEXT(http_ctx, L); |
| 72 | |
| 73 | n = lua_gettop(L); |
| 74 | |
| 75 | if (n < 1) { |
| 76 | TSError("[ts_lua][%s] ts.http.intercept need at least one param", __FUNCTION__); |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | type = lua_type(L, 1); |
| 81 | if (type != LUA_TFUNCTION) { |
| 82 | TSError("[ts_lua][%s] ts.http.intercept should use function as param, but there is %s", __FUNCTION__, lua_typename(L, type)); |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | ictx = ts_lua_create_http_intercept_ctx(L, http_ctx, n); |
| 87 | contp = TSContCreate(ts_lua_http_intercept_entry, TSMutexCreate()); |
| 88 | TSContDataSet(contp, ictx); |
| 89 | |
| 90 | TSHttpTxnIntercept(contp, http_ctx->txnp); |
| 91 | http_ctx->has_hook = 1; |
| 92 | |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | static int |
| 97 | ts_lua_http_server_intercept(lua_State *L) |
nothing calls this directly
no test coverage detected