Skip to content

Commit

Permalink
fix: lightpush returned Header is text/plain
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Oct 20, 2023
1 parent c9a339b commit 0161bcb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/waku/server/rest/lightpush_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (serv *LightpushService) postMessagev1(w http.ResponseWriter, req *http.Req
defer req.Body.Close()

if err := msg.Check(); err != nil {
writeErrOrResponse(w, err, http.StatusBadRequest)
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error()))
return
}
//
Expand All @@ -64,5 +65,10 @@ func (serv *LightpushService) postMessagev1(w http.ResponseWriter, req *http.Req
}

_, err := serv.node.Lightpush().Publish(req.Context(), msg.Message, lightpush.WithPubSubTopic(msg.PubSubTopic))
writeErrOrResponse(w, err, true)
if err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
w.Write([]byte(err.Error()))
} else {
w.WriteHeader(http.StatusOK)
}
}

0 comments on commit 0161bcb

Please sign in to comment.