August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this subsection, you are going to see the Go code of a HTTPS server. The implementation of the simple HTTPS server is saved in https.go and it is going to be presented in three parts.
The first part of https.go is as follows:
package main
import (
"fmt"
"net/http"
)
var PORT = ":1443"
The second part of https.go contains the following code:
func Default(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "This is an example HTTPS server!\n")
}
This function will handle all incoming HTTPS connections.
The last part of https.go is as follows:
func main() { http.HandleFunc("/", Default) fmt.Println("Listening to port number", PORT) err := http.ListenAndServeTLS(PORT, "server.crt", "server.key", nil) if err != ...Read now
Unlock full access