-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #824 from bunkerity/dev
Merge branch "dev" into branch "ui"
- Loading branch information
Showing
109 changed files
with
1,602 additions
and
1,501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mike==2.0.0 | ||
mkdocs==1.5.3 | ||
mkdocs-material[imaging]==9.5.2 | ||
mkdocs-material[imaging]==9.5.3 | ||
mkdocs-print-site-plugin==2.3.6 | ||
pytablewriter==1.2.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
-- A module for sharing ngx.ctx between subrequests. | ||
-- Original work by Alex Zhang (openresty/lua-nginx-module/issues/1057) | ||
-- updated by 3scale/apicast. | ||
-- | ||
-- Copyright (c) 2016 3scale Inc. | ||
-- Licensed under the Apache License, Version 2.0. | ||
-- License text: See LICENSE | ||
-- | ||
-- Modifications by Kong Inc. | ||
-- * updated module functions signatures | ||
-- * made module function idempotent | ||
-- * replaced thrown errors with warn logs | ||
-- * allow passing of context | ||
-- * updated to work with new 1.19.x apis | ||
|
||
local ffi = require "ffi" | ||
local base = require "resty.core.base" | ||
require "resty.core.ctx" | ||
|
||
|
||
local C = ffi.C | ||
local ngx = ngx | ||
local var = ngx.var | ||
local ngx_log = ngx.log | ||
local ngx_WARN = ngx.WARN | ||
local tonumber = tonumber | ||
local registry = debug.getregistry() | ||
local subsystem = ngx.config.subsystem | ||
local get_request = base.get_request | ||
|
||
-- BW edits | ||
local logger = require "bunkerweb.logger":new("CTX") | ||
local ngx_ERR = ngx.ERR | ||
|
||
local ngx_lua_ffi_get_ctx_ref | ||
if subsystem == "http" then | ||
ngx_lua_ffi_get_ctx_ref = C.ngx_http_lua_ffi_get_ctx_ref | ||
elseif subsystem == "stream" then | ||
ngx_lua_ffi_get_ctx_ref = C.ngx_stream_lua_ffi_get_ctx_ref | ||
end | ||
|
||
|
||
local in_ssl_phase = ffi.new("int[1]") | ||
local ssl_ctx_ref = ffi.new("int[1]") | ||
|
||
|
||
local FFI_NO_REQ_CTX = base.FFI_NO_REQ_CTX | ||
|
||
|
||
local _M = {} | ||
|
||
|
||
function _M.stash_ref(ctx) | ||
local r = get_request() | ||
if not r then | ||
logger:log(ngx_ERR, "could not stash ngx.ctx ref: no request found") | ||
return | ||
end | ||
|
||
do | ||
local ctx_ref = var.ctx_ref | ||
if not ctx_ref or ctx_ref ~= "" then | ||
return | ||
end | ||
|
||
if not ctx then | ||
local _ = ngx.ctx -- load context if not previously loaded | ||
end | ||
end | ||
local ctx_ref = ngx_lua_ffi_get_ctx_ref(r, in_ssl_phase, ssl_ctx_ref) | ||
if ctx_ref == FFI_NO_REQ_CTX then | ||
logger:log(ngx_ERR, "could not stash ngx.ctx ref: no ctx found") | ||
return | ||
end | ||
|
||
var.ctx_ref = ctx_ref | ||
end | ||
|
||
|
||
function _M.apply_ref() | ||
local r = get_request() | ||
if not r then | ||
logger:log(ngx_ERR, "could not apply ngx.ctx: no request found") | ||
return | ||
end | ||
|
||
local ctx_ref = var.ctx_ref | ||
if not ctx_ref or ctx_ref == "" then | ||
return | ||
end | ||
|
||
ctx_ref = tonumber(ctx_ref) | ||
if not ctx_ref then | ||
return | ||
end | ||
|
||
local orig_ctx = registry.ngx_lua_ctx_tables[ctx_ref] | ||
if not orig_ctx then | ||
logger:log(ngx_ERR, "could not apply ngx.ctx: no ctx found") | ||
return | ||
end | ||
|
||
ngx.ctx = orig_ctx | ||
var.ctx_ref = "" | ||
end | ||
|
||
|
||
return _M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.