Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tarekziade/nuax
Micro-Framework in Lua
https://github.com/tarekziade/nuax
Last synced: 2 months ago
JSON representation
Micro-Framework in Lua
- Host: GitHub
- URL: https://github.com/tarekziade/nuax
- Owner: tarekziade
- Created: 2015-05-26T16:18:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-26T19:48:59.000Z (over 9 years ago)
- Last Synced: 2024-08-01T22:54:11.992Z (4 months ago)
- Language: Lua
- Size: 141 KB
- Stars: 15
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
- starred-awesome - nuax - Micro-Framework in Lua (Lua)
README
====
Nuax
====Nuax is a micro-framework based on OpenResty to write simple JSON web services.
Example::
# nginx.conf
http {
server {
listen 80;location / {
content_by_lua '
local app = require "nuax"app:get("/hello/:name", function(request, response)
response.json = {Hello=request.urlmatch.name}
end)app.main()
'
}
}Of course you can separate the Lua code into its own module and
use **content_by_lua_file**.To build your app, all you have to do is define HTTP methods
(like **app:get()**) and routes (like "/hello/:name") combos.When app.main() is called through Nginx's root location it will
try to find a corresponding match. If any is found, a Request
object is built using Nginx's request environment and a Response
object is prepared.From there, all you have to do is fill **response.json** with
whatever JSON data you want to send back to the user.Your Lua functions can access everything OpenResty has to offer
of course and use whatever libraries you want.