fix bug with lua sticky session implementation and refactor balancer
This commit is contained in:
parent
94198fce83
commit
7ac4e1db30
8 changed files with 194 additions and 299 deletions
|
|
@ -1,6 +1,34 @@
|
|||
local _M = {}
|
||||
local string_len = string.len
|
||||
local string_sub = string.sub
|
||||
local resty_str = require("resty.string")
|
||||
local resty_sha1 = require("resty.sha1")
|
||||
local resty_md5 = require("resty.md5")
|
||||
|
||||
local _M = {}
|
||||
|
||||
local function hash_digest(hash_factory, message)
|
||||
local hash = hash_factory:new()
|
||||
if not hash then
|
||||
return nil, "failed to create object"
|
||||
end
|
||||
local ok = hash:update(message)
|
||||
if not ok then
|
||||
return nil, "failed to add data"
|
||||
end
|
||||
local binary_digest = hash:final()
|
||||
if binary_digest == nil then
|
||||
return nil, "failed to create digest"
|
||||
end
|
||||
return resty_str.to_hex(binary_digest), nil
|
||||
end
|
||||
|
||||
function _M.sha1_digest(message)
|
||||
return hash_digest(resty_sha1, message)
|
||||
end
|
||||
|
||||
function _M.md5_digest(message)
|
||||
return hash_digest(resty_md5, message)
|
||||
end
|
||||
|
||||
-- given an Nginx variable i.e $request_uri
|
||||
-- it returns value of ngx.var[request_uri]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue