diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-15 21:06:56 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-15 21:06:56 +0200 |
| commit | 8790f632fe0943f5eb616897a3072b4d182a5319 (patch) | |
| tree | c5e07d5a0da5b66a95cb5f03dcc6b78d8c8bc91c /docs/src/api/go | |
| parent | 8d5d611783842d3d67604eca0fa17d24120333c0 (diff) | |
Docs: Document language-specific callback constructs
Diffstat (limited to 'docs/src/api/go')
| -rw-r--r-- | docs/src/api/go/functions.md | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/docs/src/api/go/functions.md b/docs/src/api/go/functions.md index 381f5be..fc4f0a1 100644 --- a/docs/src/api/go/functions.md +++ b/docs/src/api/go/functions.md @@ -8,7 +8,7 @@ func Register(name string, directory string, stateCallback func, debug bool) err - `directory`: The directory where the configs and logging should be stored - `stateCallback`: function with three arguments, full type: ```go - func(oldState string, newState string, data string) + func StateCallback(oldState string, newState string, data string) ``` - `debug`: Whether or not we want to enable debugging @@ -67,3 +67,10 @@ func Deregister() error ``` Returns an `error`, can be nil indicating no error + +# Note on Callbacks +Some functions (e.g. [the API for getting an OpenVPN/Wireguard config](http://localhost:3000/api/overview/getconfig.html)) need a (or multiple) callback(s) set. In Go, the callback function is given in the [Register function](#registering). The signature of this function is the following: +```go +func StateCallback(oldState string, newState string, data string) +``` +Because certain callbacks need to be set, you can simply compare against `oldState` and `newState`. To show how this can be done in practice, we will give an example in the next section. |
