Skip to content

Commit

Permalink
Dep: Update gocoap from v2 to v3
Browse files Browse the repository at this point in the history
Signed-off-by: 1998-felix <[email protected]>
  • Loading branch information
felixgateru committed Apr 18, 2024
1 parent fcc6387 commit 07c3235
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion coap/api/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ func handler(w mux.ResponseWriter, m *mux.Message) {
if err != nil {
logger.Warn(fmt.Sprintf("Error decoding message: %s", err))
resp.Code = codes.BadRequest
sendResp(w, &resp, false)
return
}
key, err := parseKey(m)
if err != nil {
logger.Warn(fmt.Sprintf("Error parsing auth: %s", err))
resp.Code = codes.Unauthorized
sendResp(w, &resp, false)
return
}
var isObs bool = false
Expand All @@ -107,7 +109,7 @@ func handler(w mux.ResponseWriter, m *mux.Message) {
isObs, err = handleGet(context.Background(), m, w, msg, key)
case codes.POST:
resp.Code = codes.Created
err = nil
err = service.Publish(m.Context(), key, msg)
default:
err = svcerr.ErrNotFound
}
Expand Down
5 changes: 4 additions & 1 deletion coap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,8 @@ func (c *client) Handle(msg *messaging.Message) error {
for _, option := range opts {
pm.SetOptionBytes(option.ID, option.Value)
}
return c.client.Conn().WriteMessage(pm)
if err = c.client.Conn().WriteMessage(pm); err != nil {
return err
}
return nil
}

0 comments on commit 07c3235

Please sign in to comment.