Building an HTTPS server in Go

It's finally time to dig into some code. Since Go is very well-suited for building modern web software, writing an HTTPS web server is easy. Let's begin by reviewing the piece of code we wrote in the preceding chapter to establish an HTTP web server:

 http.ListenAndServe(endpoint, r)

It was a single line of code, a function called ListenAndServe(), which belongs to the HTTP Go package in the standard library. The first argument to ListenAndServe() was the endpoint to which we would like our web server to listen to. So, for example, if we would like our web server to listen to local port 8181, the endpoint would be :8181 or localhost:8181. The second argument is the object that describes the HTTP routes and their ...

Get Cloud Native programming with Golang now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.