-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.go
More file actions
57 lines (47 loc) · 1.07 KB
/
hello.go
File metadata and controls
57 lines (47 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//test 2
//test 2
//test 2
package main
import (
"fmt"
"log"
"net/http"
)
func httpsWorker(done chan bool) {
fmt.Print("working...")
err := http.ListenAndServeTLS(":443", "/etc/server/server.crt", "/etc/server/server.key", nil)
if err != nil {
log.Println(err)
}
fmt.Println("https done")
// Send a value to notify that we're done.
done <- true
}
func httpWorker(done chan bool) {
fmt.Print("http working...")
err := http.ListenAndServe(":80", nil)
if err != nil {
log.Println(err)
}
fmt.Println("done")
// Send a value to notify that we're done.
done <- true
}
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, you've requested: %s\n", r.URL.Path)
})
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "0")
})
// Start a worker goroutine, giving it the channel to
// notify on.
done := make(chan bool)
go httpWorker(done)
go httpsWorker(done)
// Block until we receive a notification from the
// worker on the channel.
for i := 0; i < 2; i++ {
<-done
}
}