Skip to content

Commit

Permalink
add vars
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Oct 10, 2023
1 parent 99ac3d2 commit fa22bbc
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/ngx_http_lua_kong_request_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
#define KONG_REQUEST_ID_FORMAT "%08xD%08xD%08xD%08xD"


static ngx_int_t
ngx_http_lua_kong_variable_request_id(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);


static ngx_http_variable_t ngx_http_lua_kong_variables[] = {

{ ngx_string("kong_request_id"), NULL,
ngx_http_lua_kong_variable_request_id,
0, 0, 0 },

ngx_http_null_variable
};


static ngx_int_t
ngx_http_lua_kong_variable_request_id(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
Expand All @@ -48,3 +63,21 @@ ngx_http_lua_kong_variable_request_id(ngx_http_request_t *r,
}


ngx_int_t
ngx_http_lua_kong_add_vars(ngx_conf_t *cf)
{
ngx_http_variable_t *cv, *v;

for (cv = ngx_http_lua_kong_variables; cv->name.len; cv++) {
v = ngx_http_add_variable(cf, &cv->name, cv->flags);
if (v == NULL) {
return NGX_ERROR;
}

*v = *cv;
}

return NGX_OK;
}


0 comments on commit fa22bbc

Please sign in to comment.