This is an Asterisk AGI interface library which may be used for both classical AGI, with a standalone executable, or FastAGI, with a TCP server.
package main
import"github.com/CyCoreSystems/agi"funcmain() {
a:=agi.NewStdio()
a.Answer()
err:=a.Set("MYVAR", "foo")
iferr!=nil {
panic("failed to set variable MYVAR")
}
a.Hangup()
}Use agi.NewStdio() to get an AGI reference when running a standalone
executable.
For a TCP server, register a HandlerFunc to a TCP port:
package main
import"github.com/CyCoreSystems/agi"funcmain() {
agi.Listen(":8080", handler)
}
funchandler(a*agi.AGI) {
defera.Close()
a.Answer()
err:=a.Set("MYVAR", "foo")
iferr!=nil {
panic("failed to set variable MYVAR")
}
a.Hangup()
}