Subscribe to the Ardan Labs Insider

You’ll get our FREE Video Series & special offers on upcoming training events along with notifications on our latest blog posts.

Included in your subscription
  • Access to our free video previews
  • Updates on our latest blog posts
  • Discounts on upcoming events

Valid email required.

Submit failed. Try again or message us directly at hello@ardanlabs.com.

Thank You for Subscribing

Check your email for confirmation.

Interfaces 101 : Extensible API Handlers Ep. 10

Author image

Ardan Labs

Introduction

In episode 9, Miki discussed how a command flag can be decoded into a user defined type with the Value interface. As a recap, the Value interface consists of two methods: one for serializing the underlying concrete type and one for deserializing a string into an object. To put this interface to the test, Miki wrote a command that had a flag to specify a network address. While implementing the Set method of the Value interface, Miki demonstrated how to add validation for your program’s flags.

In this video, Miki will build an HTTP server with one endpoint to display the health of his server. The first step he took was to define a HTTP handler to illustrate how a Go handler becomes a HandlerFunc. Next, Miki will design a function signature for middleware with the goal of abstracting input and output as much as possible. Miki will then define a logging middleware that measures the time of a request. Watch and learn how you can write a HTTP handler that is extendable with middleware.

Things you will learn in this video

  • Define a route with Go’s http package.
  • The ideal design for a middleware function.
  • How to implement an HTTP server with composability in mind.
  • Define logging middleware with Go’s STD library.

Video

Go Training

We have taught Go to thousands of developers all around the world since 2014. There is no other company that has been doing it longer and our material has proven to help jump start developers 6 to 12 months ahead of their knowledge of Go. We know what knowledge developers need in order to be productive and efficient when writing software in Go.

Our classes are perfect for both experienced and beginning engineers. We start every class from the beginning and get very detailed about the internals, mechanics, specification, guidelines, best practices and design philosophies. We cover a lot about "if performance matters" with a focus on mechanical sympathy, data oriented design, decoupling and writing production software.

Capital One
Cisco
Visa
Teradata
Red Ventures

Interested in Ultimate Go Corporate Training and special pricing?

Let’s Talk Corporate Training!

Join Our Online
Education Program

Our courses have been designed from training over 30,000 engineers since 2013, and they go beyond just being a language course. Our goal is to challenge every student to think about what they are doing and why.