Book Image

Building Distributed Applications in Gin

By : Mohamed Labouardy
4 (1)
Book Image

Building Distributed Applications in Gin

4 (1)
By: Mohamed Labouardy

Overview of this book

Gin is a high-performance HTTP web framework used to build web applications and microservices in Go. This book is designed to teach you the ins and outs of the Gin framework with the help of practical examples. You’ll start by exploring the basics of the Gin framework, before progressing to build a real-world RESTful API. Along the way, you’ll learn how to write custom middleware and understand the routing mechanism, as well as how to bind user data and validate incoming HTTP requests. The book also demonstrates how to store and retrieve data at scale with a NoSQL database such as MongoDB, and how to implement a caching layer with Redis. Next, you’ll understand how to secure and test your API endpoints with authentication protocols such as OAuth 2 and JWT. Later chapters will guide you through rendering HTML templates on the server-side and building a frontend application with the React web framework to consume API responses. Finally, you’ll deploy your application on Amazon Web Services (AWS) and learn how to automate the deployment process with a continuous integration and continuous delivery (CI/CD) pipeline. By the end of this Gin book, you will be able to design, build, and deploy a production-ready distributed application from scratch using the Gin framework.
Table of Contents (16 chapters)
1
Section 1: Inside the Gin Framework
3
Section 2: Distributed Microservices
9
Section 3: Beyond the Basics

What this book covers

Chapter 1, Getting Started with Gin, gives a foundational understanding of what the Gin framework is, how it works, and what its features are. It also supplies guidelines for setting up the Go runtime and a Gin "Hello World" example.

Chapter 2, Setting up API Endpoints, covers how to build a complete RESTful API from scratch and how to generate its documentation with OpenAPI.

Chapter 3, Managing Data Persistence with MongoDB, illustrates how to store and retrieve data at scale with a NoSQL database such as MongoDB. It also covers how to optimize the API response time with Redis.

Chapter 4, Building API Authentication, is dedicated to the best practices and recommendations to follow to secure API endpoints. It demonstrates the usage of authentication protocols, including JWT, Auth0, and session cookies.

Chapter 5, Serving Static HTML in Gin, demonstrates how to build a single-page application (SPA) with a REST backend backed by a Gin RESTful API. It also shows how to render HTML templates with Gin and how to build a self-contained web application.

Chapter 6, Scaling a Gin Application, shows how to improve the performance and scalability of a Gin distributed web application with Docker and RabbitMQ.

Chapter 7, Testing Gin HTTP Routes, explores how to run automated tests with Docker. This involves running Go unit tests and integration tests, and inspecting security vulnerabilities with Snyk.

Chapter 8, Deploying the Application on AWS, demonstrates how to deploy the Gin distributed application on a server backed by AWS EC2 and how to scale it for a heavy workload on Kubernetes.

Chapter 9, Implementing a CI/CD Pipeline, introduces the CI/CD practices we should follow to automate the build, test, and deployment of a Gin application. It also covers how to implement the practices with CircleCI using a Pipeline as Code approach.

Chapter 10, Capturing Gin Application Metrics, goes a step further in order to show you how to troubleshoot and monitor with ease a running Gin application in production.