From 00f125f9b732997fd7768f13c8a6e741540649d9 Mon Sep 17 00:00:00 2001 From: Tobias Mende Date: Tue, 25 Nov 2014 08:37:33 +0100 Subject: [PATCH] Adapting the SetPath function to their comment (setting LocationPath instead of URIPath) Adapting server example to make use of the SetPath function instead of setting the option directly. (Setting an array as options value failes hence there is no such case in the toBytes function) For repeating fields, it might be good to set the option in a for loop, when receiving an array. --- example/server/coap_server.go | 2 +- message.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/server/coap_server.go b/example/server/coap_server.go index 52adb9b..81ce2d6 100644 --- a/example/server/coap_server.go +++ b/example/server/coap_server.go @@ -19,7 +19,7 @@ func main() { Payload: []byte("hello to you!"), } res.SetOption(coap.ContentFormat, coap.TextPlain) - res.SetOption(coap.LocationPath, m.Path()) + res.SetPath(m.Path()) return res } diff --git a/message.go b/message.go index 41926ff..bdbeae1 100644 --- a/message.go +++ b/message.go @@ -339,9 +339,9 @@ func (m *Message) SetPathString(s string) { // SetPath updates or adds a LocationPath attribute on this message. func (m *Message) SetPath(s []string) { - m.RemoveOption(URIPath) + m.RemoveOption(LocationPath) for _, p := range s { - m.AddOption(URIPath, p) + m.AddOption(LocationPath, p) } }