Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status

GHoKo is a web application that listens to web-hooks, scripted by Lua and written in Golang. Web-hooks usually are used for CI, Automated testing or something else.

For example, GHoKo has been used in many browser based game projects for CI and system operations.



All useful scripts were put at the directory shell.

Befor building, the proper lua librarie must be installed. E.g. Ubuntu 14.04, it is liblua5.1-0-dev.


go get

The ghoko library implement http.Handler and can be embeded into other projects.

go get

Have a fun!



Executing following command:

$ ${fullpath}/ghoko -h

Some help information:

Usage of ./ghoko:
	-addr=":8080": Address of http service
	-defualt="gitlab": Default code hosting site
	-log="": log to write (empty for STDOUT)
	-log-level="all": log level ('error', 'warning', 'message', 'debug', 
		'all' and 'none' are combined with '|')
	-pid="": PID file
	-root="/": Root path of URL
	-script="./": Path of lua files
	-secret="": Secret token
	-tls-cert="": TLS cert file
	-tls-key="": TLS key file

The pattern of hook URL is


$schema could be HTTP or HTTPS either. When both two tls-* flags were specified correctly, The HTTPS will be used.

You can set root path of URL through root flag.

Eg. script was set to /ghoko. And if root is /hook/v1, the request will evaluate /ghoko/foo/bar.lua. If root was set to /hook and requesting the same URL, /ghoko/v1/foo/bar.lua will be evaluated.

$params can be used for passing custom values into script through URL. HTTP method, POST is also accepted. If Content-Type in the request header contains json, it means passing enconded JSON data through POST-Body. Otherwise, it is a common post with form data.

All of them will combine into a global variable ghoko.Params, it can be used in Lua scripts.

Usually, GHoKo evaluates lua scripts asynchronous. Ghoko-Sync is a magic header for requesting ghoko in synchronized way. When it is equal ture(string), two functions ghoko.WriteBody and ghoko.WriteHeader can be used for response data and HTTP status to HTTP clients.

Another magic header is GHoKo-Id. It tells ghoko do not generate ID but using client specified one.


GHoKo use Lua as the scripting language. GHoKo will pass the Request into Lua script as a user data.

You can use user data in the Lua script.

Following variables and functions can be called in Lua:

  • ghoko.Id - Every request has a global unique Id
  • ghoko.Params - Params passed by URL\POST-BODY(JSON format)
  • ghoko.Call(id, name, params) - Call lua script and pass params to it
  • ghoko.Debug(msg)/ghoko.Debugf(format, msg) - Output debug infomations
  • ghoko.Message(msg)/ghoko.Messagef(format, msg) - Output message infomations
  • ghoko.Warning(msg)/ghoko.Warningf(format, msg) - Output warning infomations
  • ghoko.Error(err)/ghoko.Errorf(format, msg) - Output error infomations
  • ghoko.Write(msg) - Write something to HTTP clients (sync only)
  • ghoko.WriteHeader(status) - Assign HTTP status (sync only)
  • ghoko.Get(url) - GET a remote url, _secret will be passed
  • ghoko.PostJSON(url, params) - POST to a remote url with JSON encoded params
  • ghoko.Post(url, params) - POST to a remote url with a form

Web Hook

To set GitLab's web hook: Your repo --> settrings --> Web Hooks.

To set GitHub's web hook is a little more complicated. Following: Your repo --> Settings --> Service Hooks --> WebHook URLs.

Here is an example for gitlab (gitlab.lua):

or for github (github.lua):

We have writen demo scripts for you. The scripts will print the repo and commits's informations.


Open Source

See LICENSE for more information.


A web application that listens to web-hooks, scripted by Lua and written in Golang.




No releases published


No packages published
You can’t perform that action at this time.