Introduction

In this video, Paulo shows the benefit of leveraging generic functions to write less code that does more. He starts by walking you through an API server he initially wrote that makes use of Go’s default HTTP handlers with a sprinkle of GORM to manage database transactions. He then refactors that code by introducing the concept of adapter functions.

Paulo’s approach consists of decoupling his business logic with his API code. To achieve this, he defines an adapter function that will establish a bridge between his business logic and API server handlers. This proves to be an effective way to abstract request processing and handling. This approach also promotes code reusability because the business logic is loosely coupled with the API service invoking it.

Things you will learn in this video

  • Launching an API server with PPROF to evaluate performance.
  • Use adapter methods to build a bridge between an API call and business logic.
  • Implement a generic method to streamline encoding and decoding data.

Video

Trusted by Top Technology Companies

We've built our reputation as educators and bring that mentality to every project. When you partner with us, your team will learn best practices and grow along the way.

30,000+

Engineers Trained

1,000+

Companies Worldwide

14+

Years in Business