-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for POST, PUT, DELETE methods #5
Conversation
Adds support for POST, PUT, and DELETE methods, and moves to throwing errors and returning objects. Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
Updates the simple test example to show more capabilities and interactions. Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
@@ -90,6 +99,15 @@ func (c *CoAP) client(cc goja.ConstructorCall) *goja.Object { | |||
if err := client.obj.DefineDataProperty("observe", rt.ToValue(client.Observe), goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_TRUE); err != nil { | |||
common.Throw(rt, err) | |||
} | |||
if err := client.obj.DefineDataProperty("put", rt.ToValue(client.Put), goja.FLAG_FALSE, goja.FLAG_FALSE, goja.FLAG_TRUE); err != nil { | |||
common.Throw(rt, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i get it, but it feels so odd to read this in Go code. 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, ends up being a little easier to work with on the JS side 👍🏻
// Create new client and connect. | ||
let client; | ||
try { | ||
client = new Client("coap.golioth.io:5684"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to open source this, should this be pointing to Golioth's production CoAP gateway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so -- it makes this example real.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Given we've got rate-limiting in place, we have some guardrails against a DDOS event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, someone could mount a DDOS attack whether this code existed or not.
Adds support for POST, PUT, and DELETE methods, and moves to throwing
errors and returning objects.
Signed-off-by: Daniel Mangum georgedanielmangum@gmail.com