Skip to content

Commit 789ca95

Browse files
authored
Merge pull request #25 from pf93/feature-support-check-cert-dispatch
support check domain cert dispatch by rule invoke chain
2 parents 7618f0c + a28e12d commit 789ca95

5 files changed

Lines changed: 21 additions & 11 deletions

File tree

cloud/pkg/router/listener/http.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ func (rh *RestHandler) httpHandler(w http.ResponseWriter, r *http.Request) {
109109
return
110110
}
111111

112-
matchPath, exist := rh.matchedPath(r.RequestURI)
112+
matchPath, exist := rh.matchedPath(r.URL.Path)
113113
if !exist {
114-
klog.Warningf("URL format incorrect: %s", r.RequestURI)
114+
klog.Warningf("URL format incorrect: %s", r.URL.Path)
115115
w.WriteHeader(http.StatusNotFound)
116116
if _, err := w.Write([]byte("Request error")); err != nil {
117117
klog.Errorf("Response write error: %s, %s", r.RequestURI, err.Error())
@@ -146,6 +146,7 @@ func (rh *RestHandler) httpHandler(w http.ResponseWriter, r *http.Request) {
146146
params["request"] = r
147147
params["timeout"] = rh.restTimeout
148148
params["data"] = b
149+
params["param"] = r.URL.RawQuery
149150

150151
v, err := handle(params)
151152
if err != nil {

cloud/pkg/router/provider/servicebus/servicebus.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type ServiceBus struct {
2727
targetPath string
2828
servicePort string
2929
nodeName string
30+
protocol string
3031
TargetURL string
3132
}
3233

@@ -116,6 +117,7 @@ func (sf *servicebusFactory) GetTarget(ep *v1.RuleEndpoint, targetResource map[s
116117
cli := &ServiceBus{
117118
targetPath: targetPath,
118119
servicePort: ep.Spec.Properties["service_port"],
120+
protocol: ep.Spec.Properties["protocol"],
119121
}
120122
return cli
121123
}
@@ -129,6 +131,7 @@ func (sb *ServiceBus) GoToTarget(data map[string]interface{}, stop chan struct{}
129131
request.Method, ok = data["method"].(string)
130132
request.Header, ok = data["header"].(http.Header)
131133
request.Body, ok = data["data"].([]byte)
134+
request.Protocol = sb.protocol
132135
if !ok {
133136
err := errors.New("data transform failed")
134137
klog.Error(err.Error())
@@ -141,7 +144,7 @@ func (sb *ServiceBus) GoToTarget(data map[string]interface{}, stop chan struct{}
141144
if !ok || param == "" {
142145
resource = resource + sb.targetPath
143146
} else {
144-
resource = resource + strings.TrimSuffix(sb.targetPath, "/") + "/" + strings.TrimPrefix(param, "/")
147+
resource = resource + strings.TrimSuffix(sb.targetPath, "/") + "?" + strings.TrimPrefix(param, "?")
145148
}
146149
msg.SetResourceOperation(resource, request.Method)
147150
msg.FillBody(request)

common/types/http.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import "net/http"
44

55
// HTTPRequest is used structure used to unmarshal message content from cloud
66
type HTTPRequest struct {
7-
Header http.Header `json:"header"`
8-
Body []byte `json:"body"`
9-
Method string `json:"method"`
10-
URL string `json:"url"`
7+
Header http.Header `json:"header"`
8+
Body []byte `json:"body"`
9+
Method string `json:"method"`
10+
Protocol string `json:"protocol"`
11+
URL string `json:"url"`
1112
}
1213

1314
// HTTPResponse is HTTP request's response structure used to send response to cloud

edge/pkg/servicebus/servicebus.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ func processMessage(msg *beehiveModel.Message) {
168168

169169
//send message with resource to the edge part
170170
operation := httpRequest.Method
171-
targetURL := "http://127.0.0.1:" + r[0] + r[1]
171+
if httpRequest.Protocol == "" {
172+
httpRequest.Protocol = "http"
173+
}
174+
targetURL := httpRequest.Protocol + "://127.0.0.1:" + r[0] + r[1]
172175
resp, err := uc.HTTPDo(operation, targetURL, httpRequest.Header, httpRequest.Body)
173176
if err != nil {
174177
m := "error to call service"

edge/pkg/servicebus/util/httpclient.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ func (client *URLClient) HTTPDo(method, rawURL string, headers http.Header, body
6868

6969
func (client *URLClient) clientHasPrefix(url, pro string) {
7070
if strings.HasPrefix(url, pro) {
71-
if transport, ok := client.Client.Transport.(*http.Transport); ok {
72-
transport.TLSClientConfig = client.TLS
73-
}
71+
client.Client.Transport = &http.Transport{
72+
TLSClientConfig: &tls.Config{
73+
InsecureSkipVerify: true,
74+
},
75+
}
7476
}
7577
}
7678

0 commit comments

Comments
 (0)