| 94 | } |
| 95 | |
| 96 | static int |
| 97 | ts_lua_http_server_intercept(lua_State *L) |
| 98 | { |
| 99 | TSCont contp; |
| 100 | int type, n; |
| 101 | ts_lua_http_ctx *http_ctx; |
| 102 | ts_lua_http_intercept_ctx *ictx; |
| 103 | |
| 104 | GET_HTTP_CONTEXT(http_ctx, L); |
| 105 | |
| 106 | n = lua_gettop(L); |
| 107 | |
| 108 | if (n < 1) { |
| 109 | TSError("[ts_lua][%s] ts.http.server_intercept need at least one param", __FUNCTION__); |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | type = lua_type(L, 1); |
| 114 | if (type != LUA_TFUNCTION) { |
| 115 | TSError("[ts_lua][%s] ts.http.server_intercept should use function as param, but there is %s", __FUNCTION__, |
| 116 | lua_typename(L, type)); |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | ictx = ts_lua_create_http_intercept_ctx(L, http_ctx, n); |
| 121 | contp = TSContCreate(ts_lua_http_intercept_entry, TSMutexCreate()); |
| 122 | TSContDataSet(contp, ictx); |
| 123 | |
| 124 | TSHttpTxnServerIntercept(contp, http_ctx->txnp); |
| 125 | http_ctx->has_hook = 1; |
| 126 | |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | static int |
| 131 | ts_lua_http_intercept_entry(TSCont contp, TSEvent event, void *edata) |
nothing calls this directly
no test coverage detected