keplerproject / wsapi

WSAPI is an API that abstracts the web server from Lua web applications.
http://keplerproject.github.io/wsapi
74 stars 33 forks source link

Can't get setup #44

Closed dannysmc95 closed 4 years ago

dannysmc95 commented 6 years ago

Hi there,

So I have tried getting this to work with Nginx, and I have it all working using the following Nginx configuration:

server {
    listen 80;
    root /home/websites/luatest;
    index index.php index.html index.lua;
    server_name <domain>;

    location ~ \.lua$ {
        root /home/websites/luatest;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.lua;
        fastcgi_split_path_info ^(.+\.lua)(.*)\$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

I have then also spawned the FCGI workers like so: spawn-fcgi -a 127.0.0.1 -p 9000 -F 4 -- /usr/bin/wsapi.fcgi --cgilua -f

And if I put the following code in index.lua in the root:

-- Define table
local _M = {};

-- Define run function
function _M.run(wsapi_env)
    local headers = { ["Content-type"] = "text/html" }

    local function hello_text()
        coroutine.yield("<html><body>")
        coroutine.yield("<p>Hello Wsapi!</p>")
        coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
        coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
        coroutine.yield("</body></html>")
    end

    return 200, headers, coroutine.wrap(hello_text)
end

return _M;

And that shows me the correct details, but I can't seem to find where any of the POST, GET, SESSION is, so I can make a basic page with it, but can't access anything else? I am really confused. Any help would be awesome, thanks!

I am trying to aim at something similar to PHP, but using Lua, where based on the file loaded via Nginx, I can serve it to the Fast CGI handler and let it process, meaning I can write code (somewhat similarly) to PHP. But I am struggling, I have everything showing data, but for some reason the basic web server information, like URL, GET, POST etc, I can't find.

Any help would be super appreciated.

Thanks,

dannysmc95 commented 4 years ago

Dead/Not Maintained