Video summary
Golang Microservices Full Course #22 - API Gateway (Reverse Proxy)
Main summary
Key takeaways
Overview
The episode begins the project’s transition from a monolithic Go wallet application to microservices. Because exposing each service on a separate port would complicate client apps, the instructor introduces an API Gateway as a single public entry point, planned for port 8080. The gateway will route requests to services such as users, wallets, and transactions on their own ports. It is described as a reverse proxy implemented with Go’s standard library.
Main Implementation Steps and Concepts
- Go workspace and repository layout: The instructor creates a
microservicesdirectory, initializes a Go workspace withgo.work, and adds an API Gateway module and a shared module. The monolith’s code is copied into the gateway area as a starting point. - Shared code module: Common configuration, logging, utilities, and error-handling code are moved or copied into a shared module so services can reuse them. The instructor notes that this can reduce duplication and make shared functionality easier to test and maintain.
- Gateway scaffolding: The project gets an internal reverse-proxy package, CORS middleware, a
cmdentry point, and environment-based configuration for backend service URLs. The subtitles do not clearly establish that routing requests to backend services was fully tested in this episode. - Logger initialization fix: Running the gateway reveals a nil-pointer error because the logger was not initialized. After consulting an AI coding assistant, the instructor changes the shared logger initialization to initialize itself when needed while preserving the existing parameterless initialization function for compatibility.
- Docker setup: A multi-stage Dockerfile is added, with a build stage and a smaller production image. The production stage includes CA certificates and a non-root user. Because the gateway uses local workspace modules, the Docker build must run from the microservices repository root and include the workspace and relevant module files.
- Docker Compose: The instructor configures the gateway and supporting services, including MySQL and MailHog, and troubleshoots service names, dependencies, and existing containers. The gateway image is rebuilt, the containers are started, and their health status is checked.
- Testing and project status: A gateway health endpoint is checked, and the instructor reports that the gateway container is healthy. Testing calls through to the backend services is left for later. The changes are committed to a feature branch and merged into the main branch.
Reviews, Guides, or Tutorials
This is a hands-on implementation tutorial covering Go workspaces, shared modules, API Gateway scaffolding, reverse-proxy architecture, Docker builds, and Compose setup. It follows earlier monolith bug-fixing and code-review work, but does not include a separate formal review or a complete end-to-end demonstration of service routing.
Main Speakers and Sources
- Main speaker: The course instructor, narrating the coding and troubleshooting.
- Additional source consulted: An AI coding assistant, used for help with Docker and logger-related issues.
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.