1- --- @mod rest-nvim.script rest.nvim pre-request/request handler module
1+ --- @mod rest-nvim.script.lua rest.nvim lua script runner
2+ --- @diagnostic disable : duplicate-set-field
23
4+ --- @type rest.ScriptClient
35local script = {}
46
57local logger = require (" rest-nvim.logger" )
@@ -12,7 +14,7 @@ local logger = require("rest-nvim.logger")
1214
1315--- @param ctx rest.Context
1416--- @return rest.PreScriptEnv
15- function script . create_prescript_env (ctx )
17+ local function create_prescript_env (ctx )
1618 --- Global Environment variables passed to pre-request scripts
1719 --- @class rest.PreScriptEnv
1820 local env = {
3941--- @param ctx rest.Context
4042--- @param res rest.Response
4143--- @return rest.HandlerEnv
42- function script . create_handler_env (ctx , res )
44+ local function create_handler_env (ctx , res )
4345 --- Global Environment variables passed to response handler scripts
4446 --- @class rest.HandlerEnv
4547 local env = {
8587--- @param s string
8688--- @param env table
8789--- @return function
88- function script . load (s , env )
90+ local function load_lua (s , env )
8991 local f , error_msg = load (s , " script_variable" , " bt" , env )
9092 if error_msg then
9193 logger .error (error_msg )
9799--- @param ctx rest.Context
98100--- @return function
99101function script .load_pre_req_hook (s , ctx )
100- return script . load (s , script . create_prescript_env (ctx ))
102+ return load_lua (s , create_prescript_env (ctx ))
101103end
102104
103105--- @param s string
104106--- @param ctx rest.Context
105107--- @return function
106108function script .load_post_req_hook (s , ctx )
107109 return function (res )
108- script . load (s , script . create_handler_env (ctx , res ))()
110+ return load_lua (s , create_handler_env (ctx , res ))()
109111 end
110112end
111113
0 commit comments