Building Distributed Applications in Gin: A hands-on guide for Go developers to build and deploy distributed web apps with the Gin framework (Paperback)

Labouardy, Mohamed

  • 出版商: Packt Publishing
  • 出版日期: 2021-07-23
  • 售價: $1,910
  • 貴賓價: 9.5$1,815
  • 語言: 英文
  • 頁數: 482
  • 裝訂: Quality Paper - also called trade paper
  • ISBN: 1801074852
  • ISBN-13: 9781801074858
  • 相關分類: Go 程式語言
  • 海外代購書籍(需單獨結帳)
    無現貨庫存(No stock available)



Key Features

  • Explore the commonly used functionalities of Gin to build web applications
  • Become well-versed with rendering HTML templates with the Gin engine
  • Solve commonly occurring challenges such as scaling, caching, and deployment

Book Description

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/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.

What you will learn

  • Build a production-ready REST API with the Gin framework
  • Scale web applications with event-driven architecture
  • Use NoSQL databases for data persistence
  • Set up authentication middleware with JWT and Auth0
  • Deploy a Gin-based RESTful API on AWS with Docker and Kubernetes
  • Implement a CI/CD workflow for Gin web apps

Who this book is for

This book is for Go developers who are comfortable with the Go language and seeking to learn REST API design and development with the Gin framework. Beginner-level knowledge of the Go programming language is required to make the most of this book.



  • 探索使用 Gin 建立網頁應用程式的常用功能

  • 熟悉使用 Gin 引擎渲染 HTML 模板

  • 解決常見的擴展、快取和部署問題


Gin 是一個高效能的 HTTP 網頁框架,用於在 Go 語言中建立網頁應用程式和微服務。本書旨在通過實際示例教授您 Gin 框架的各種細節。

您將從探索 Gin 框架的基礎知識開始,然後進一步建立一個真實世界的 RESTful API。在此過程中,您將學習如何編寫自定義中間件,了解路由機制,以及如何綁定用戶數據並驗證傳入的 HTTP 請求。本書還演示了如何使用 NoSQL 數據庫(如 MongoDB)存儲和檢索大規模數據,以及如何使用 Redis 實現快取層。接下來,您將了解如何使用身份驗證協議(如 OAuth 2 和 JWT)保護和測試 API 端點。後面的章節將指導您在服務器端渲染 HTML 模板,並使用 React 網頁框架構建前端應用程式以消耗 API 響應。最後,您將在 Amazon Web Services(AWS)上部署應用程式,並學習如何使用持續集成/持續交付(CI/CD)流程自動化部署過程。

通過閱讀本書,您將能夠從頭開始設計、構建和部署一個生產就緒的分佈式應用程式,使用 Gin 框架。


  • 使用 Gin 框架構建生產就緒的 REST API

  • 使用事件驅動架構擴展網頁應用程式

  • 使用 NoSQL 數據庫進行數據持久化

  • 使用 JWT 和 Auth0 設置身份驗證中間件

  • 使用 Docker 和 Kubernetes 在 AWS 上部署基於 Gin 的 RESTful API

  • 為 Gin 網頁應用程式實現 CI/CD 工作流程


本書適合已經熟悉 Go 語言並希望學習使用 Gin 框架進行 REST API 設計和開發的 Go 開發人員。需要具備初級水平的 Go 編程語言知識,以充分利用本書的內容。


Mohamed Labouardy is the CTO and co-founder of Crew, and a DevSecOps evangelist. He is the founder of Komiser, a regular conference speaker, and author of several books around Serverless and Distributed Applications. He is also a contributor to numerous open-source projects such as Jenkins, Docker, and Telegraf.


Mohamed Labouardy 是 Crew 的 CTO 兼共同創辦人,也是一位 DevSecOps 傳道者。他是 Komiser 的創始人,經常在會議上演講,並撰寫了幾本關於無伺服器和分散式應用的書籍。他也是 Jenkins、Docker 和 Telegraf 等眾多開源項目的貢獻者。


Table of Contents

  1. Getting Started with Gin
  2. Setting up API Endpoints
  3. Managing Data Persistence with MongoDB
  4. Building API authentication.
  5. Serving Static HTML in Gin
  6. Scaling a Gin application
  7. Testing Gin HTTP Routes
  8. Deploying the application on AWS
  9. Implementing a CI/CD Pipeline
  10. Capturing Gin application metrics



  1. 開始使用 Gin

  2. 設置 API 端點

  3. 使用 MongoDB 管理數據持久性

  4. 建立 API 認證

  5. 在 Gin 中提供靜態 HTML

  6. 擴展 Gin 應用程式

  7. 測試 Gin HTTP 路由

  8. 在 AWS 上部署應用程式

  9. 實施 CI/CD 流程

  10. 捕獲 Gin 應用程式指標