Once the web application development is over, it's likely that we will deploy it to the servers. While deploying, it is always recommended to run the web application on an HTTPS protocol rather than HTTP, especially for the servers that are publicly exposed. In this recipe, we will learn how we can do this in Go.
Moving an HTTP server to HTTPS
How to do it...
- Create https-server.go, where we will define a handler that will just write Hello World! to an HTTP response stream for all HTTPS requests, as follows:
package main
import
(
"fmt"
"log"
"net/http"
)
const
(
CONN_HOST = "localhost"
CONN_PORT = "8443"
HTTPS_CERTIFICATE = "domain.crt"
DOMAIN_PRIVATE_KEY...