Skip to content

Commit

Permalink
fix resourceAddress prefix (redhat-cne#75)
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Ding <jackding@gmail.com>
  • Loading branch information
jzding committed Aug 29, 2024
1 parent 6103cbb commit 3ecae44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions v2/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,16 +454,16 @@ func (s *Server) getCurrentState(w http.ResponseWriter, r *http.Request) {
return
}

if !strings.HasPrefix(resourceAddress, "/") {
resourceAddress = fmt.Sprintf("/%s", resourceAddress)
}

eventSubscribers := s.subscriberAPI.GetClientIDAddressByResource(resourceAddress)
if len(eventSubscribers) == 0 {
respondWithStatusCode(w, http.StatusNotFound, fmt.Sprintf("subscription not found for %s", resourceAddress))
return
}

if !strings.HasPrefix(resourceAddress, "/") {
resourceAddress = fmt.Sprintf("/%s", resourceAddress)
}

// this is placeholder not sending back to report
out := channel.DataChan{
Address: resourceAddress,
Expand Down
4 changes: 2 additions & 2 deletions v2/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ var (
port = 8990
apHost = "localhost"
apPath = "/api/ocloudNotifications/v2/"
resource = "test/test"
resourceNoneSubscribed = "test/nonesubscribed"
resource = "/test/test"
resourceNoneSubscribed = "/test/nonesubscribed"
storePath = "."
ObjSub pubsub.PubSub
ObjPub pubsub.PubSub
Expand Down

0 comments on commit 3ecae44

Please sign in to comment.