AGIServer

package module
v0.0.0-...-81a9475 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 8 Imported by: 0

README

FastAGI-go

Asterisk FastAGI server for GoLang

Install
go get https://github.com/BlayD91/FastAGI-go
Usage
import "time"

func callHandler(r Request) {
	r.SendCommand("ANSWER")

	if r.Params["agi_language"] == "en" {
		r.SendCommand("SET LANG_CODE 1")
	} else {
		r.SendCommand("SET LANG_CODE 0")
	}

	r.SendCommand("HANGUP")
}

func main() {
	server := NewServer(":8000", 10*time.Second, 10*1024)
	err := server.AddRoute("inner_call", callHandler)
	if err != nil {
		panic(err)
	}
	go server.ListenAndServe()

	time.Sleep(10 * time.Second)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseText

func ParseText(text string) map[string]string

Types

type Request

type Request struct {
	Params map[string]string
	// contains filtered or unexported fields
}

func (*Request) Busy

func (r *Request) Busy()

func (*Request) SendCommand

func (r *Request) SendCommand(command string)

type Route

type Route func(Request)

type Server

type Server struct {
	Addr         string
	IdleTimeout  time.Duration
	MaxReadBytes int64
	// contains filtered or unexported fields
}

func (*Server) AddRoute

func (srv *Server) AddRoute(name string, route Route) error

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe()

func (*Server) Shutdown

func (srv *Server) Shutdown()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL