~tsileo/blobstash

d875ca672574e12a66d88df405c34b7062f33444 — Thomas Sileo a month ago 4e3ecd0
extra: add new Lua helper
1 files changed, 8 insertions(+), 0 deletions(-)

M pkg/extra/extra.go
M pkg/extra/extra.go => pkg/extra/extra.go +8 -0
@@ 5,6 5,7 @@ import (
	"io/ioutil"
	"net/http"
	"path/filepath"
	"strings"

	"github.com/yuin/gopher-lua"
)


@@ 33,6 34,13 @@ func setupExtra(e *Extra) func(*lua.LState) int {
				}
				return 1
			},
			"replace": func(L *lua.LState) int {
				in := L.ToString(1)
				toreplace := L.ToString(2)
				replacement := L.ToString(3)
				L.Push(lua.LString(strings.Replace(in, toreplace, replacement, 1)))
				return 1
			},
			"embed_http_resource": func(L *lua.LState) int {
				url := L.ToString(1)