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.

Abstract

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.

Video

GoLab is a conference made by Develer.
Develer is a company based in Campi Bisenzio, near Florence. Our motto is : "Technology to give life to your products". We produce hardware and software to create exceptional products and to improve industrial processes and people's well being.
In Develer we have passion for the new technologies and we offer our clients effective solutions that are also efficient, simple and safe for the end users. We also believe in a friendly and welcoming environment where anybody can give their contribution. This passion and this vision are what we've been driven to organize our conference "made by developers for developers".


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.
©2024 GoLab | The international conference on Go in Florence-Design & devCantiere Creativo-Made withDatoCMS