Skip to content

Commit

Permalink
Merge pull request #33 from reubenmiller/fix-support-proxy-paths
Browse files Browse the repository at this point in the history
fix: support using fixed url path prefixes for websocket communication
  • Loading branch information
reubenmiller authored Jan 15, 2024
2 parents 73e1287 + a5b4baf commit 2c4b7b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 5 additions & 3 deletions pkg/c8y/notification2/notification2.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ func getEndpoint(host string, subscription Subscription) *url.URL {
if index := strings.Index(host, "://"); index > -1 {
fullHost = "wss" + host[index:]
}
c8yhost, _ := url.Parse(fullHost)
c8yhost.Path = "/notification2/consumer/"
tempUrl, err := url.Parse(fullHost)
if err != nil {
Logger.Fatalf("Invalid url. %s", err)
}
c8yhost := tempUrl.ResolveReference(&url.URL{Path: "notification2/consumer/"})
c8yhost.RawQuery = "token=" + subscription.Token

if subscription.Consumer != "" {
c8yhost.RawQuery += "&consumer=" + subscription.Consumer
}

return c8yhost
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/c8y/notification2service.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (s *Notification2Service) CreateClient(ctx context.Context, opt Notificatio
return nil, err
}

client := notification2.NewNotification2Client(s.client.BaseURL.Host, nil, notification2.Subscription{
client := notification2.NewNotification2Client(s.client.BaseURL.String(), nil, notification2.Subscription{
TokenRenewal: func(v string) (string, error) {
return s.RenewToken(ctx, Notification2ClientOptions{
Token: v,
Expand Down
4 changes: 1 addition & 3 deletions pkg/c8y/realtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ func getRealtimeURL(host string) *url.URL {
c8yhost.Scheme = "wss"
}

c8yhost.Path = "/cep/realtime"

return c8yhost
return c8yhost.ResolveReference(&url.URL{Path: "cep/realtime"})
}

// NewRealtimeClient initializes a new Bayeux client. By default `http.DefaultClient`
Expand Down

0 comments on commit 2c4b7b7

Please sign in to comment.