lua-resty-template 动态html模板
今天在Nginx + Lua的项目中有一个使用场景,是要根据请求数据对Html页面进行数据动态展示。
首先说明使用的Nginx模块的github:https://github.com/bungle/lua-resty-template#lua-api
具体内容可以自行查看,今天主要说明一下今天遇到的问题:
跳转还是下载?
首先是在lua中引入了模板
local template = require "resty.template"
然后在下文中经过一些列操作,最终指向跳转页面,并且将需要填充的内容传递过去
template.render("jumpview.html", { message = url })
不过执行了几次,最终的结果并不是直接跳转到指定的模板页面,而是将模板的html下载下来。
几经尝试,最终的解决办法是在服务对应的nginx conf配置文件中的location中添加
default_type 'text/html'