Skip to content

Commit

Permalink
[policy] trigger post_action phase
Browse files Browse the repository at this point in the history
sharing context to post_action enables executing the phase
with all context from the main request - including policy chain
  • Loading branch information
mikz committed Jan 4, 2018
1 parent 19b3a9b commit f8cd303
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions gateway/conf.d/apicast.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ location @out_of_band_authrep_action {

set_by_lua $original_request_time 'return ngx.var.request_time';

content_by_lua_block { require('apicast.executor'):post_action() }
content_by_lua_block {
require('resty.ctx').apply()
require('apicast.executor'):post_action()
}

log_by_lua_block {
ngx.var.post_action_impact = ngx.var.request_time - ngx.var.original_request_time
Expand All @@ -70,12 +73,17 @@ location / {
set $version '';
set $real_url null;

set $ctx_ref -1;

set $post_action_impact null;
set $original_request_id null;

proxy_ignore_client_abort on;

rewrite_by_lua_block { require('apicast.executor'):rewrite() }
rewrite_by_lua_block {
require('resty.ctx').stash()
require('apicast.executor'):rewrite()
}
access_by_lua_block { require('apicast.executor'):access() }
body_filter_by_lua_block { require('apicast.executor'):body_filter() }
header_filter_by_lua_block { require('apicast.executor'):header_filter() }
Expand Down
1 change: 1 addition & 0 deletions t/apicast-policy-chains.t
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ running phase: access
running phase: balancer
running phase: header_filter
running phase: body_filter
running phase: post_action
4 changes: 2 additions & 2 deletions t/apicast.t
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Content-Type: text/plain; charset=utf-8
no mapping rules!
--- error_code: 404
--- error_log
could not find proxy for request
skipping after action, no cached key

=== TEST 5: no mapping rules matched configurable error
The message is configurable and status also.
Expand Down Expand Up @@ -136,7 +136,7 @@ GET /?user_key=value
no mapping rules!
--- error_code: 412
--- error_log
could not find proxy for request
skipping after action, no cached key

=== TEST 6: authentication credentials invalid default error
There are defaults defined for the error message, the content-type, and the
Expand Down

0 comments on commit f8cd303

Please sign in to comment.