-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathhttp_request_rule.go
More file actions
30 lines (23 loc) · 870 Bytes
/
http_request_rule.go
File metadata and controls
30 lines (23 loc) · 870 Bytes
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
package dataplane
import (
"fmt"
"net/http"
"github.com/haproxytech/models"
)
func (c *Dataplane) HTTPRequestRules(parentType, parentName string) ([]models.HTTPRequestRule, error) {
type resT struct {
Data []models.HTTPRequestRule `json:"data"`
}
var res resT
err := c.makeReq(http.MethodGet, fmt.Sprintf("/v1/services/haproxy/configuration/http_request_rules?parent_type=%s&parent_name=%s", parentType, parentName), nil, &res)
if err != nil {
return nil, err
}
return res.Data, nil
}
func (t *tnx) CreateHTTPRequestRule(parentType, parentName string, rule models.HTTPRequestRule) error {
if err := t.ensureTnx(); err != nil {
return err
}
return t.client.makeReq(http.MethodPost, fmt.Sprintf("/v1/services/haproxy/configuration/http_request_rules?parent_type=%s&parent_name=%s&transaction_id=%s", parentType, parentName, t.txID), rule, nil)
}