You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# install golang# https://go.dev/doc/install
wget https://go.dev/dl/go1.19.3.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
# compile example libraries
make
# run nginx
make run
# or specify nginx executable file path# make run NGINX_BIN=/path/to/nginx# in another terminal# curl the tests
make test
Library Skelton
//export libffi_initfunclibffi_init(cfg_cstr*C.char, tq unsafe.Pointer) C.int {
gofunc() {
for {
// poll a tasktask:=C.ngx_http_lua_ffi_task_poll(tq)
// if task queue is done, then quitiftask==nil {
break
}
// get the request message from the taskvarrlen C.intr:=C.ngx_http_lua_ffi_get_req(task, &rlen)
// copy the request as response, allocated by C malloc()// note that both request and response would be freed by nginxres:=C.malloc(C.ulong(rlen))
C.memcpy(res, unsafe.Pointer(r), C.ulong(rlen))
C.ngx_http_lua_ffi_respond(task, 0, (*C.char)(res), rlen)
}
}()
return0
}