Book Image

Building RESTful Web services with Go

By : Naren Yellavula
Book Image

Building RESTful Web services with Go

By: Naren Yellavula

Overview of this book

REST is an architectural style that tackles the challenges of building scalable web services and in today's connected world, APIs have taken a central role on the web. APIs provide the fabric through which systems interact, and REST has become synonymous with APIs. The depth, breadth, and ease of use of Go, makes it a breeze for developers to work with it to build robust Web APIs. This book takes you through the design of RESTful web services and leverages a framework like Gin to implement these services. The book starts with a brief introduction to REST API development and how it transformed the modern web. You will learn how to handle routing and authentication of web services along with working with middleware for internal service. The book explains how to use Go frameworks to build RESTful web services and work with MongoDB to create REST API. You will learn how to integrate Postgres SQL and JSON with a Go web service and build a client library in Go for consuming REST API. You will learn how to scale APIs using the microservice architecture and deploy the REST APIs using Nginx as a proxy server. Finally you will learn how to metricize a REST API using an API Gateway. By the end of the book you will be proficient in building RESTful APIs in Go.
Table of Contents (20 chapters)
Title Page
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Chapter 11. Using an API Gateway to Monitor and Metricize REST API

Once we have developed our API, we need to expose it to the outside world. In that journey, we deploy them. But is that sufficient? Don't we need to track our API? Which clients are connecting? What is the latency of requests, and so on and so forth? There are many other post-API development steps that one should follow to make their API production grade. They are authentication, logging, rate limiting, and so on. The best way to add those features is to use an API gateway. In this chapter, we will explore an open-source API gateway called Kong. Open-source software is preferable to cloud providers because of the reduced risk of vendor lock. All the API gateways differ in the implementation but perform the same task.

In this chapter, we will cover the following topics:

  • Why is an API gateway needed?
  • Introducing Kong, an open-source API gateway
  • Example illustration in Docker
  • Adding developed API to Kong
  • Logging in Kong
  • Authentication...