找回密码
 立即注册
查看: 485|回复: 0

初始化代码脚本该如何使用?

[复制链接]

17

主题

1

回帖

109

积分

管理员

积分
109
发表于 2024-6-15 19:18:33 | 显示全部楼层 |阅读模式
初始化非必须,一般用于需要在站点启动前进行某些资源初始化,例如:`MySQL连接池`,`缓存资源` 等。
⚠ 不需要初始化,修改`config.ini`配置文件 `Initialization_script=` 参数为空即可

要求:
必须返回`bool`型变量:`true`  = 成功并继续,`false` = 终止运行

示例:
local interceptor = require("fastweb.interceptor")
local subscribe = require("fastweb.subscribe")
----------拦截器示例-------------
-- 拦截所有请求
interceptor.add("/*.*","/api/init/denied_interceptor.lua")

----------订阅示例-------------
subscribe.add("/user/*.*","/api/user.lua")


-- 输出初始化成功
print("init ok")
return true



您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Fastweb

GMT+8, 2024-9-17 04:00 , Processed in 0.025550 second(s), 18 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表