gluaweb

package module
v0.0.0-...-e7f8cc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2018 License: MIT Imports: 5 Imported by: 0

README

gluaweb

在Gopher Lua中使用"net/http"实现web app开发

Install

go get github.com/yuin/gopher-lua
go get github.com/yuin/gluamapper
go get github.com/zhu327/gluaweb

Example

package main

import (
	"github.com/yuin/gopher-lua"
	"github.com/zhu327/gluaweb"
	"net/http"
)

type helloHandler struct{}

func (h *helloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	L := lua.NewState()
	defer L.Close()
	ctx := gluaweb.NewWebContext(w, r).WebContext(L)
	L.SetGlobal("web", ctx)
	if err := L.DoString(`

        web.Write("hello world!")

    `); err != nil {
		panic(err)
	}
}

func main() {
	http.Handle("/", &helloHandler{})
	http.ListenAndServe(":8080", nil)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CookieToTable

func CookieToTable(L *lua.LState, c *http.Cookie) *lua.LTable

func MapToTable

func MapToTable(L *lua.LState, values map[string][]string) *lua.LTable

func RequestToTable

func RequestToTable(L *lua.LState, r *http.Request) *lua.LTable

Types

type WebContext

type WebContext struct {
	// contains filtered or unexported fields
}

func NewWebContext

func NewWebContext(w http.ResponseWriter, r *http.Request) *WebContext

func (*WebContext) BasicAuth

func (ctx *WebContext) BasicAuth(L *lua.LState) int

func (*WebContext) Cookie

func (ctx *WebContext) Cookie(L *lua.LState) int

func (*WebContext) Cookies

func (ctx *WebContext) Cookies(L *lua.LState) int

func (*WebContext) FormValue

func (ctx *WebContext) FormValue(L *lua.LState) int

func (*WebContext) HeaderAdd

func (ctx *WebContext) HeaderAdd(L *lua.LState) int

func (*WebContext) HeaderDel

func (ctx *WebContext) HeaderDel(L *lua.LState) int

func (*WebContext) HeaderGet

func (ctx *WebContext) HeaderGet(L *lua.LState) int

func (*WebContext) HeaderSet

func (ctx *WebContext) HeaderSet(L *lua.LState) int

func (*WebContext) PostFormValue

func (ctx *WebContext) PostFormValue(L *lua.LState) int

func (*WebContext) ProtoAtLeast

func (ctx *WebContext) ProtoAtLeast(L *lua.LState) int

func (*WebContext) Redirect

func (ctx *WebContext) Redirect(L *lua.LState) int

func (*WebContext) Referer

func (ctx *WebContext) Referer(L *lua.LState) int

func (*WebContext) Request

func (ctx *WebContext) Request(L *lua.LState) int

func (*WebContext) RequestBody

func (ctx *WebContext) RequestBody(L *lua.LState) int

func (*WebContext) RequestForm

func (ctx *WebContext) RequestForm(L *lua.LState) int

func (*WebContext) RequestHeader

func (ctx *WebContext) RequestHeader(L *lua.LState) int

func (*WebContext) SetCookie

func (ctx *WebContext) SetCookie(L *lua.LState) int

func (*WebContext) UrlPath

func (ctx *WebContext) UrlPath(L *lua.LState) int

func (*WebContext) UrlQuery

func (ctx *WebContext) UrlQuery(L *lua.LState) int

func (*WebContext) UserAgent

func (ctx *WebContext) UserAgent(L *lua.LState) int

func (*WebContext) WebContext

func (ctx *WebContext) WebContext(L *lua.LState) *lua.LTable

func (*WebContext) Write

func (ctx *WebContext) Write(L *lua.LState) int

func (*WebContext) WriteHeader

func (ctx *WebContext) WriteHeader(L *lua.LState) int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL