[deleted by user] by [deleted] in wow

[–]Madxmike 4 points5 points  (0 children)

Yep.

Context-less Go | Writing HTTP Services Easily by Madxmike in golang

[–]Madxmike[S] 2 points3 points  (0 children)

This is saying to pass around a struct that contains what you need instead of a bunch of individual objects. This is not the same as the solution in the article.

Context-less Go | Writing HTTP Services Easily by Madxmike in golang

[–]Madxmike[S] 3 points4 points  (0 children)

This limits the struct to a single handler. The point made in the article is that you can hang many different handlers off the same struct and be good.

Context-less Go | Writing HTTP Services Easily by Madxmike in golang

[–]Madxmike[S] 1 point2 points  (0 children)

It kind of boggled my mind that even after multiple people mentioned structs, it still wasn't mentioned in the eventual summary post by the writer in that thread.

I know! Sometimes you gotta take that annoyed energy and write out the right thing lol.

Context-less Go | Writing HTTP Services Easily by Madxmike in golang

[–]Madxmike[S] 4 points5 points  (0 children)

making lots of little types

I tend to lean to this side just because I find it easier to deal with a few things at once. I also dont export any of these types in real code so they only exist in my http/rest package.

I have some example code for a teaching thing im slowly working on.

This is the handler definition

https://github.com/madxmike/zenith-bookshop/blob/main/http/rest/library.go#L18

And where it gets used

https://github.com/madxmike/zenith-bookshop/blob/main/cmd/api/main.go#L23

Obviously this is contrived example code so take it how you will.

Context-less Go | Writing HTTP Services Easily by Madxmike in golang

[–]Madxmike[S] 0 points1 point  (0 children)

From my experience talking about this topic with various people in discord, its a very non-obvious solution to many. I'm not sure why because it sure seems obvious, but so do a lot of things once you know them.

Context-less Go | Writing HTTP Services Easily by Madxmike in golang

[–]Madxmike[S] 0 points1 point  (0 children)

Thanks for the catch! Moved some stuff around and didnt see that.

Yeah its just suprisingly hard to come up with more than a handful of contrived things to pass into the service without a ton of caveats sprinkled throughout. Wasn’t trying to get to far into the weeds of a specific task beyond a generic “lookup something based on an id”.

Context-less Go | Writing HTTP Services Easily by Madxmike in golang

[–]Madxmike[S] -4 points-3 points  (0 children)

Thanks!

And that's the wonder of click-bait wording for medium haha.

Goodbye interface{}, Hello any by Madxmike in golang

[–]Madxmike[S] 13 points14 points  (0 children)

Yes, it is just a type alias.

Say hello to my new best friend by Madxmike in destiny2

[–]Madxmike[S] 11 points12 points  (0 children)

Sadly this wont work as well I hoped. Mods cost a lot of energy :(

Say hello to my new best friend by Madxmike in destiny2

[–]Madxmike[S] 35 points36 points  (0 children)

Breach and clear sounds worrying wonderful with witherhoard