cjoudrey / gluahttp

gluahttp: an http module for gopher-lua
MIT License
57 stars 23 forks source link

Command line usage #24

Open ghost opened 4 years ago

ghost commented 4 years ago

Is it possible?

$ cat sun.lua
local http = require("http")

$ glua sun.lua
sun.lua:1: module http not found:
no field package.preload['http']
CreateFile .\http.lua: The system cannot find the file specified.
CreateFile C:\opt\lua\http.lua: The system cannot find the path specified.
CreateFile C:\opt\lua\http\init.lua: The system cannot find the path specified.

https://github.com/yuin/gopher-lua#standalone-interpreter

erikdubbelboer commented 4 years ago

That is possible yes but you'll have to modify https://github.com/yuin/gopher-lua/blob/f46add6fdb5c3d93936a840f565e8e753a79ca34/cmd/glua/glua.go#L62 And add

L.PreloadModule("http", gluahttp.NewHttpModule(&http.Client{}).Loader)