Gluapp status    Godoc Reference

HTTP framework for GopherLua.


  • Simple
  • No 3rd party requirements except gopher-lua
  • Rely on Go template language
  • Same request/response idioms as Go HTTP lib
  • Comes with a basic (and optional) router
  • First-class JSON support
  • Included HTTP client
  • Support importing dependency from GitHub on the fly with require2


local router = require('router').new()

router:get('/hello/:name', function(params)
  app.response:write('hello ' ..



  • Write Lua modules documentation
  • A module for web scrapping
  • A basic key-value store module
  • read_file/write_file/read_json helper
Expand ▾ Collapse ▴




This section is empty.


This section is empty.


func Exec

func Exec(conf *Config, code string, w http.ResponseWriter, r *http.Request) error

    Exec run the code as a Lua script

    func SetupGlue

    func SetupGlue(L *lua.LState, conf *Config, w http.ResponseWriter, r *http.Request) error

      SetupGlue setup the "glue"/std lib for use outside of gluapp


      type App

      type App struct {
      	// contains filtered or unexported fields

        App represents a Lua app

        func NewApp

        func NewApp(conf *Config) (*App, error)

        func (*App) Exec

        func (a *App) Exec(w http.ResponseWriter, r *http.Request) (*Response, error)

          Exec executes the app in the given context, but it does not write the output to the `http.ResponseWriter`, you need to call `Response.WriteTo(w)` manually.

          Most of the time, you should use `App` as a `http.HandlerFunc` (or call `App.ServeHTTP` manually).

          func (*App) ServeHTTP

          func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

            ServeHTTP implements the `http.HandlerFunc` interface.

            type Config

            type Config struct {
            	// Path for looking up resources (Lua files, templates, public assets)
            	Path string
            	// Define the app entrypoint, default to `app.lua` (only valid for apps)
            	Entrypoint string
            	// HTTP client, if not set, `http.DefaultClient` will be used
            	Client *http.Client
            	// Hook for adding/setting additional modules/global variables
            	SetupState func(L *lua.LState, w http.ResponseWriter, r *http.Request) error
            	// Hook executed just after the script execution, just before the request is written
            	AfterScriptExecHook func(L *lua.LState) error
            	// Hook for custom `log` backend, defautl to `fmt.Println`
            	LogHook func(logLine string) error
            	// Stack trace will be displayed in debug mode
            	Debug bool
            	TemplateFuncMap template.FuncMap

              Config represents an app configuration

              type Response

              type Response struct {
              	Body       []byte
              	Header     http.Header
              	StatusCode int
              	// contains filtered or unexported fields

                Response represents the HTTP response

                func (*Response) WriteTo

                func (resp *Response) WriteTo(w http.ResponseWriter)

                  WriteTo dumps the respons to the actual response.


                  Path Synopsis
                  package util that regroups multiple useful Lua modules.
                  package util that regroups multiple useful Lua modules.