File tree Expand file tree Collapse file tree 4 files changed +15
-10
lines changed
Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 11if ngx then
2- if ngx .config and ngx .config .is_console then
3- return require (" lapis.nginx.resty_http" )
4- else
5- return require (" lapis.nginx.http" )
6- end
2+ return require (" lapis.nginx.http" )
73elseif package.loaded [" lapis.running_server" ] == " cqueues" then
84 return require (" http.compat.socket" )
95else
Original file line number Diff line number Diff line change 11if ngx
2- if ngx. config and ngx. config. is_console
3- -- the "location capture" client is not compatible with resty
4- require " lapis.nginx.resty_http"
5- else
6- require " lapis.nginx.http"
2+ require " lapis.nginx.http"
73elseif package.loaded [ " lapis.running_server" ] == " cqueues"
84 require " http.compat.socket"
95else
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ simple = function(req, body)
5959end
6060local request
6161request = function (url , str_body )
62+ local _exp_0 = ngx .get_phase ()
63+ if " timer" == _exp_0 then
64+ return require (" lapis.nginx.resty_http" ).request (url , str_body )
65+ end
6266 local ltn12 = require (" ltn12" )
6367 local config = lapis_config .get ()
6468 local start_time
Original file line number Diff line number Diff line change @@ -93,6 +93,15 @@ simple = (req, body) ->
9393 res. body, res. status, res. header
9494
9595request = ( url, str_body) ->
96+ -- handle phases not compatible with location.capture
97+ -- NOTE: while we are testing resty_http integration we are only exposing in
98+ -- timers. You will need to manually opt into lapis.nginx.resty_http to use
99+ -- it in other phases for now, as you may want the existing behavior of an
100+ -- error to be raised if you're doing http requests in weird places
101+ switch ngx. get_phase!
102+ when " timer"
103+ return require ( " lapis.nginx.resty_http" ) . request url, str_body
104+
96105 ltn12 = require " ltn12"
97106
98107 config = lapis_config. get!
You can’t perform that action at this time.
0 commit comments