Skip to content
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

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

hasheddan
Copy link
Contributor

Adds support for POST, PUT, and DELETE methods, and moves to throwing
errors and returning objects.

Signed-off-by: Daniel Mangum georgedanielmangum@gmail.com

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)

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. 😆

Copy link
Contributor Author

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");

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?

Copy link
Contributor Author

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.

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.

Copy link
Contributor Author

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.

@hasheddan hasheddan merged commit 22b2a45 into main Jul 11, 2023
1 check passed
@hasheddan hasheddan deleted the feat/remaining-methods branch August 1, 2023 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants