|
@@ -161,7 +161,7 @@ static void reg_function(struct lua_State *L, const char *name,
|
|
lua_rawset(L, -3);
|
|
lua_rawset(L, -3);
|
|
}
|
|
}
|
|
|
|
|
|
-static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
|
|
|
|
|
|
+void mg_prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
|
|
const struct mg_request_info *ri = mg_get_request_info(conn);
|
|
const struct mg_request_info *ri = mg_get_request_info(conn);
|
|
extern void luaL_openlibs(lua_State *);
|
|
extern void luaL_openlibs(lua_State *);
|
|
int i;
|
|
int i;
|
|
@@ -171,6 +171,8 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
|
|
{ extern int luaopen_lsqlite3(lua_State *); luaopen_lsqlite3(L); }
|
|
{ extern int luaopen_lsqlite3(lua_State *); luaopen_lsqlite3(L); }
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+ if (conn == NULL) return;
|
|
|
|
+
|
|
// Register mg module
|
|
// Register mg module
|
|
lua_newtable(L);
|
|
lua_newtable(L);
|
|
|
|
|
|
@@ -243,7 +245,7 @@ static int handle_lsp_request(struct mg_connection *conn, const char *path,
|
|
} else {
|
|
} else {
|
|
// We're not sending HTTP headers here, Lua page must do it.
|
|
// We're not sending HTTP headers here, Lua page must do it.
|
|
if (ls == NULL) {
|
|
if (ls == NULL) {
|
|
- prepare_lua_environment(conn, L);
|
|
|
|
|
|
+ mg_prepare_lua_environment(conn, L);
|
|
if (conn->ctx->callbacks.init_lua != NULL) {
|
|
if (conn->ctx->callbacks.init_lua != NULL) {
|
|
conn->ctx->callbacks.init_lua(conn, L);
|
|
conn->ctx->callbacks.init_lua(conn, L);
|
|
}
|
|
}
|