-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhaproxy_example_test.go
More file actions
58 lines (45 loc) · 1.17 KB
/
haproxy_example_test.go
File metadata and controls
58 lines (45 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package haproxy
import (
"fmt"
)
func ExampleNew() {
// start
ha := New("/var/run/haproxy.sock")
// clear all entries in ACL
_ = ha.ClearACL("inc/blacklist.lst")
}
func ExampleConn_AddACL() {
// Initialize
ha := New("/var/run/haproxy.sock")
// Get ACL entries from file in config (via -f in haproxy cfg)
acls, _ := ha.GetACL("inc/blacklist.lst")
// Check if it exists and add
if acls["/bad/path"] == "" {
ha.AddACL("inc/blacklist.lst", acls["/bad/path"])
}
}
func ExampleConn_DeleteACL() {
// Initialize
ha := New("/var/run/haproxy.sock")
// Get ACL entries from file in config (via -f in haproxy cfg)
acls, _ := ha.GetACL("inc/blacklist.lst")
// Check if it exists and delete
if acls["/bad/path"] != "" {
ha.DeleteACL("inc/blacklist.lst", acls["/bad/path"])
}
}
func ExampleConn_GetACL() {
// Initialize
ha := New("/var/run/haproxy.sock")
// Get ACL entries from file in config (via -f in haproxy cfg)
acls, _ := ha.GetACL("inc/blacklist.lst")
for k, v := range acls {
fmt.Println(k, ":\t", v)
}
}
func ExampleConn_ClearACL() {
// Initialize
ha := New("/var/run/haproxy.sock")
// clear all entries in ACL
_ = ha.ClearACL("inc/blacklist.lst")
}