ENGLISH

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

Book information

Publisher
Packt Publishing
Year
2021
ISBN
1801074852, 9781801074858
Language
english
Format
PDF
Filesize
27 MB (28475526 bytes)
Pages
482\482
Time added
2021-10-08 06:34:06

Description

An effective guide to learning how to build a large-scale distributed application using the wide range of functionalities in Gin Key FeaturesExplore the commonly used functionalities of Gin to build web applicationsBecome well-versed with rendering HTML templates with the Gin engineSolve commonly occurring challenges such as scaling, caching, and deploymentBook 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 learnBuild a production-ready REST API with the Gin frameworkScale web applications with event-driven architectureUse NoSQL databases for data persistenceSet up authentication middleware with JWT and Auth0Deploy a Gin-based RESTful API on AWS with Docker and KubernetesImplement a CI/CD workflow for Gin web appsWho 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. Table of ContentsGetting Started with GinSetting up API EndpointsManaging Data Persistence with MongoDBBuilding API authentication.Serving Static HTML in GinScaling a Gin applicationTesting Gin HTTP RoutesDeploying the application on AWSImplementing a CI/CD PipelineCapturing Gin application metrics Cover Title Page Copyright and Credits Dedication Contributors Table of Contents Preface Section 1: Inside the Gin Framework Chapter 1: Getting Started with Gin Technical requirements What is Gin? Setting up the Go environment Linux/FreeBSD Windows MacOS Integrated development environment Installing Go tools Installing and configuring Gin Dependency management in Golang Writing a custom HTTP handler Summary Questions Further reading Section 2: Distributed Microservices Chapter 2: Setting Up API Endpoints Technical requirements Exploring API functionality Defining the data model HTTP endpoints Implementing HTTP routes POST /recipes GET /recipes PUT /recipes/{id} DELETE /recipes/{id} GET /recipes/search Writing the OpenAPI Specification Installing Go Swagger Swagger metadata Summary Questions Further reading Chapter 3: Managing Data Persistence with MongoDB Technical requirements Running a MongoDB Server Installing Docker CE Running a MongoDB container Configuring Go's MongoDB driver Exploring MongoDB queries The InsertMany operation The Find operation The InsertOne operation The UpdateOne operation Designing the project's layout Caching an API with Redis Running Redis in Docker Optimizing MongoDB queries Performance benchmark Summary Questions Further reading Chapter 4: Building API Authentication Technical requirements Exploring authentication Using API keys Introducing JWTs Sign-in HTTP handler Renewing a JWT Hashing and salting passwords Persisting client sessions and cookies Authenticating with Auth0 Building an HTTPS server Self-signed certificates Summary Questions Further reading Chapter 5: Serving Static HTML in Gin Technical requirements Serving static files Rendering HTML templates Creating the view templates Creating reusable templates Building a self-contained web application Bundling static files Building a SPA Getting started with React Exploring React components Resolving cross-origin requests Summary Questions Further reading Chapter 6: Scaling a Gin Application Technical requirements Scaling workloads with a message broker Deploying RabbitMQ with Docker Exploring the Producer/Consumer pattern Scaling horizontally with Docker replicas Using Docker multi-stage builds Scaling services with Docker Compose Using the NGINX reverse proxy Caching assets with HTTP cache headers Setting HTTP caching headers Summary Further reading Section 3: Beyond the Basics Chapter 7: Testing Gin HTTP Routes Technical requirements Testing Gin HTTP handlers Generating code coverage reports Performing integration tests with Docker Discovering security vulnerabilities Gosec Securing Go modules with Snyk Running Postman collections Scripting in Postman Running collections with Newman Summary Questions Further reading Chapter 8: Deploying the Application on AWS Technical requirements Deploying on EC2 instance Launching an EC2 instance SSL offloading with an application load balancer Deploying on Amazon ECS Storing images in a private repository Creating an ECS cluster Deploying on Kubernetes with Amazon EKS Configuring kubectl Migrating a Docker Compose workflow to Kubernetes Summary Questions Further reading Chapter 9: Implementing a CI/CD Pipeline Technical requirements Exploring CI/CD practices Continuous integration Continuous deployment Continuous delivery Building a CI workflow Pipeline as Code Maintaining multiple runtime environments Implementing continuous delivery Improving the feedback loop with Slack Summary Questions Further reading Chapter 10: Capturing Gin Application Metrics Technical requirements Exposing Gin metrics with Prometheus Instrumenting a Gin application Monitoring server-side metrics Creating a Grafana notification channel Streaming Gin logs to the ELK platform Deploying the ELK stack with Docker Writing Grok expressions Updating the Gin logging format Summary Further reading Conclusion Assessments Chapter 1 – Getting started with Gin Chapter 2 – Setting up API Endpoints Chapter 3 – Managing Data Persistence with MongoDB Chapter 4 – Building API Authentication Chapter 5 – Serving Static HTML in Gin Chapter 7 – Testing Gin HTTP Routes Chapter 8 – Deploying the Application on AWS Chapter 9 – Implementing a CI/CD Pipeline Why subscribe? Other Books You May Enjoy About PACKT Index _1l1bm710bow9 _1u6bmpycvjt5 _h1e1w96ut64g _8pw2ngoe9nv _m509lwjgfp9r _yi1ji9sl74cz _j5oeabpnmywf _GoBack _GoBack

Similar books