GithubHelp home page GithubHelp logo

nuax's Introduction

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.

nuax's People

Contributors

tarekziade avatar

Stargazers

Andreas Motl avatar Jim Weng avatar Victor Burre avatar Avelino avatar Álvaro Justen avatar Osvaldo Santana Neto avatar Mohab Usama avatar Beat avatar Slavisa Djukic avatar Fairiz 'Fi' Azizi avatar Ryan Campbell avatar Fernando Grunevald avatar Mathieu Leplatre avatar Vaidik Kapoor avatar Bruno Rocha avatar

Watchers

James Cloos avatar Fairiz 'Fi' Azizi avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.