use request uri and regex to choose callbacks

This commit is contained in:
Luna 2022-12-06 13:48:09 -03:00
parent 766b1d2aff
commit eefdecb1e9
2 changed files with 32 additions and 16 deletions

View file

@ -6,6 +6,11 @@ function webfingerCallback(cfg)
local resource = args['resource']
if resource ~= nil then
-- TODO this is O(n) but we can make it O(1) by doing a funny and making
-- cfg.accounts be transformed into keys in a table
--
-- this would require us to do some setup() callback as well as
-- the request() callback
for _, account in ipairs(cfg.accounts) do
if resource == account then
return true
@ -27,7 +32,6 @@ return {
Useful for small instances.
]],
apiVersion=1,
callback=webfingerCallback,
callbacks = {
['/.well-known/webfinger'] = webfingerCallback
},