Skip to content

Commit 5796f01

Browse files
authored
feat: Add HTTPS support to REST (#986)
* feat: add HTTPS support to REST Signed-off-by: Yangsta911 <[email protected]> * refactor: Update Address struct to remove Protocol field and use Scheme Signed-off-by: Yangsta911 <[email protected]> --------- Signed-off-by: Yangsta911 <[email protected]>
1 parent 583c141 commit 5796f01

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

clients/http/subscription_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func addSubscriptionRequest() requests.AddSubscriptionRequest {
2626
return requests.NewAddSubscriptionRequest(
2727
dtos.Subscription{
2828
Name: TestSubscriptionName,
29-
Channels: []dtos.Address{dtos.NewRESTAddress(TestHost, TestPort, http.MethodGet)},
29+
Channels: []dtos.Address{dtos.NewRESTAddress(TestHost, TestPort, http.MethodGet, "http")},
3030
Receiver: TestReceiver,
3131
Categories: []string{TestCategory},
3232
Labels: []string{TestLabel},
@@ -41,7 +41,7 @@ func updateSubscriptionRequest() requests.UpdateSubscriptionRequest {
4141
return requests.NewUpdateSubscriptionRequest(
4242
dtos.UpdateSubscription{
4343
Name: &name,
44-
Channels: []dtos.Address{dtos.NewRESTAddress(TestHost, TestPort, http.MethodPut)},
44+
Channels: []dtos.Address{dtos.NewRESTAddress(TestHost, TestPort, http.MethodPut, "http")},
4545
},
4646
)
4747
}

dtos/address.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ type RESTAddress struct {
6868
InjectEdgeXAuth bool `json:"injectEdgeXAuth,omitempty"`
6969
}
7070

71-
func NewRESTAddress(host string, port int, httpMethod string) Address {
71+
func NewRESTAddress(host string, port int, httpMethod string, scheme string) Address {
7272
return Address{
73-
Type: common.REST,
74-
Host: host,
75-
Port: port,
73+
Type: common.REST,
74+
Host: host,
75+
Port: port,
76+
Scheme: scheme,
7677
RESTAddress: RESTAddress{
7778
HTTPMethod: httpMethod,
7879
},
@@ -160,7 +161,7 @@ func ToAddressModel(a Address) models.Address {
160161
case common.REST:
161162
address = models.RESTAddress{
162163
BaseAddress: models.BaseAddress{
163-
Type: a.Type, Host: a.Host, Port: a.Port,
164+
Type: a.Type, Host: a.Host, Port: a.Port, Scheme: a.Scheme,
164165
},
165166
Path: a.RESTAddress.Path,
166167
HTTPMethod: a.RESTAddress.HTTPMethod,

dtos/requests/subscription_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var (
2424
testHost = "host"
2525
testPort = 123
2626
testSubscriptionChannels = []dtos.Address{
27-
dtos.NewRESTAddress(testHost, testPort, http.MethodGet),
27+
dtos.NewRESTAddress(testHost, testPort, http.MethodGet, "http"),
2828
dtos.NewEmailAddress([]string{"[email protected]"}),
2929
dtos.NewMQTTAddress(testHost, testPort, "publisher", "topic"),
3030
dtos.NewZeroMQAddress(testHost, testPort, "topic"),

0 commit comments

Comments
 (0)