REST in Peace: using generics to remove REST boilerplate

Copy pasting boilerplate about HTTP handlers is exciting and funny for the first 3 webservices you code in Go. After that, it gets pretty annoying.

Generics provide a way to abstract that while keeping a strong type system.
RIP is an attempt to make REST in Go even simpler.

Golab #1
60 min
November 20th, 2023


What if creating an endpoint to handle a REST resource was as simple as:

type MyResource struct {}
rp := rip.ResourceProvider[MyResource](db)
http.HandleFunc(rip.HandleResource[MyResource]("/my_resource", rp)

And then, GET gets, POST creates, PUT updates and DELETE deletes, automatically, no other code involved for simple CRUD? And you specialize your resource provider if you need something more complex than that, but still without having to deal with HTTP specificities.

We'll explore how generics can give you just that, and how it is implemented, so you can see all that code you wouldn't have to write anymore.

Stay connected

You can subscribe to our newsletter to stay updated on the latest news and announcements. Follow us on social media to join our community and engage with other attendees, speakers, and staff. We're on Twitter, Mastodon, Youtube and Facebook. Don't forget to use our official hashtag #GoLab2023 to share your experience and connect with other attendees on social media.

Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2023 GoLab | The international conference on Go in Florence-Design & devCantiere Creativo-Made withDatoCMS