I. How HTTP Servers are Put Together in Go
Crack open a basic Golang HTTP server and see how it works.
This is a series of articles about Golang's HTTP capabilities. I pry into Golang's http
module, try to figure out wtf is going on, and foolishly try to create my own Reverse Proxy.
Read these in order to follow along!
Crack open a basic Golang HTTP server and see how it works.
See how Golang (ab)uses Handlers when accepting HTTP requests.
We'll use our knowledge of Handlers to create middleware for our Go web applications.
We'll use Golang Context objects to add shared data amongst our middleware and request handlers.
Let's start building a reverse proxy.
Check out the stdlib Reverse Proxy! It does a lot of work for us.
We'll start to create our own Reverse Proxy, onto which we'll eventually be adding a bunch of features.
Golang has a Single Host Reverse Proxy. We'll expand on it by making it multi-host.
So far we've just listened on port 80 for connections. Let's allow our proxy to listen on any port, and support TLS connections.
Our proxy isn't very graceful. If we turn it off, it cuts off all current connections. But Go handles this for us! We just need to orchestrate it. Let's see how.
Remember when I called a reverse proxy "basically just a load balancer"? Ours doesn't balance any load. Let's fix that!
More articles coming!