Building Distributed Applications in Gin
Mohamed Labouardy
- 482 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Building Distributed Applications in Gin
Mohamed Labouardy
About This Book
An effective guide to learning how to build a large-scale distributed application using the wide range of functionalities in GinKey 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 deploymentBook DescriptionGin 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 appsWho this book is forThis 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.
Frequently asked questions
Information
Section 1: Inside the Gin Framework
- Chapter 1, Getting Started with Gin
Chapter 1: Getting Started with Gin
- What is Gin?
- Go runtime and integrated development environment (IDE)
- Go modules and dependency management
- Writing a Gin web application
Technical requirements
- Some programming experience. The code in this chapter is pretty simple, but it helps to know something about Go.
- A tool to edit your code with. Any text editor you have will work fine. Most text editors have good support for Go. The most popular are Visual Studio Code (VSCode) (free), GoLand (paid), and Vim (free).
- A command terminal. Go works well using any Terminal on Linux and Mac, and on PowerShell or CMD in Windows.
What is Gin?
- Simple and consistent: Go has a rich set of library packages with powerful standard libraries for testing, error management, and concurrency.
- Fast and scalable: Go is a general-purpose programming language developed for the multi-core reality of today's computers. It has built-in concurrency with Goroutines and channels. Goroutines provide lightweight, threaded execution. Declaring a Goroutine is as simple as adding the go keyword before a function.
- Efficient: Go provides efficient execution and compilation. Go is also statically linked, which means that the compiler invokes a linker in the last step that resolves all library references. This means we would get one binary executable after compiling a Go program with no external dependencies. Moreover, it offers efficient memory utilization with a built-in garbage collector (Go exhibits many similarities with low-level programming languages such as C or C++).
- Community and support: Go is backed by Google and has an ever growing ecosystem and numerous contributors to the language on GitHub. Moreover, many online resources (tutorials, videos, and books) are available for getting started with Go.