| 27 | } |
| 28 | |
| 29 | func 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 | } |