Exemplo n.º 1
0
func TestHappyRead(t *testing.T) {
	// register the modules
	modprobe.Install("mod_mock", NewModMock)

	input := []byte(`
	{"id": "getping",
     "method": "GET",
     "enabled": true,
     "pattern": "/ping/:hola",
     "chain": [
  	    {"ref": "mod_mock", 
  	     "params": {
  	     	"optiona1": "a1", 
  	     	"optiona2": "a2"}},
	    {"ref": "mod_mock", 
	     "params": {
	     	"optiona1": "b1"}
	     }
	     ]
	}`)
	p, err := newProxyFromJson(input)
	assert.Nil(t, err)
	assert.Equal(t, p.GetId(), "getping")
	assert.Equal(t, p.GetMethod(), "GET")
	assert.Equal(t, p.IsEnabled(), true)
	assert.Equal(t, p.GetPattern(), "/ping/:hola")
	assert.Equal(t, len(p.GetChain().GetModules()), 2)

	modType := reflect.TypeOf(p.GetChain().GetModules()[0])

	fmt.Printf("All: %+v\n", modType)
	fmt.Printf("Name: %s\n", modType.Name())
	fmt.Printf("Pkg: %s\n", modType.PkgPath())

	fmt.Printf("Kind: %s\n", modType.Kind())
}
Exemplo n.º 2
0
func init() {
	modprobe.Install("mod_exec", NewExec)
}
Exemplo n.º 3
0
func init() {
	modprobe.Install("mod_access", NewAccess)
}
Exemplo n.º 4
0
func init() {
	modprobe.Install("mod_rewrite", NewRewrite)
}
Exemplo n.º 5
0
func init() {
	modprobe.Install("mod_http_lb", NewHttpLoadbalancer)
}
Exemplo n.º 6
0
func init() {
	modprobe.Install("mod_basic_auth", NewBasicAuth)
}
Exemplo n.º 7
0
func init() {
	modprobe.Install("mod_docker", NewDocker)
}