When an API requires implementation details from the user, many developers use an interface for help. However, another way to allow developers to provide implementation details for an API is to accept a function instead. Go supports declaring function types which can be used to define a contract similar to how interfaces define a contract. A good example of an API that uses functions over an interface is the HTTP package. The HTTP package has the user bind a handler function into different routes.

In this video, Miki will define a Go HTTP handler to act as a health check function. The handler function Miki writes needs to have the necessary parameters to satisfy the Go HTTP HandlerFunc contract. While implementing the handler, Miki demonstrates the practicality and impact function contracts have on overall developer experience. Watch and learn the role of each parameter in a Go HTTP function and some pitfalls to avoid when routing HTTP requests.

Things you will learn in this video

  • The roles of the HTTP HandlerFunc parameters.
  • Setup and route a Go HTTP handler.
  • A use case of function signatures in Go.


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.


Engineers Trained


Companies Worldwide


Years in Business