MCPcopy Create free account
hub / github.com/Apress/pro-go / main

Function main

24 - HTTP Servers/httpserver/main.go:29–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27}
28
29func main() {
30 http.Handle("/message", StringHandler{ "Hello, World"})
31 http.Handle("/favicon.ico", http.NotFoundHandler())
32 http.Handle("/", http.RedirectHandler("/message", http.StatusTemporaryRedirect))
33
34 fsHandler := http.FileServer(http.Dir("./static"))
35 http.Handle("/files/", http.StripPrefix("/files", fsHandler))
36
37 go func () {
38 err := http.ListenAndServeTLS(":5500", "certificate.cer",
39 "certificate.key", nil)
40 if (err != nil) {
41 Printfln("HTTPS Error: %v", err.Error())
42 }
43 }()
44
45 err := http.ListenAndServe(":5000", http.HandlerFunc(HTTPSRedirect))
46 if (err != nil) {
47 Printfln("Error: %v", err.Error())
48 }
49}

Callers

nothing calls this directly

Calls 2

PrintflnFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected