forked from shahriarb/build_sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
30 lines (27 loc) · 744 Bytes
/
main.go
File metadata and controls
30 lines (27 loc) · 744 Bytes
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
package main
import (
"io"
"io/ioutil"
"net/http"
)
func hello(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello world again!\n")
resp, err := http.Get("http://web.cloud66.local/counts")
if err != nil {
// handle error
io.WriteString(w, "Count from web.cloud66.local is: <<unavailable>>")
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
io.WriteString(w, "Count from web.cloud66.local is: <<unavailable>>")
return
}
io.WriteString(w, "Count from web.cloud66.local is: "+string(body))
}
func main() {
http.HandleFunc("/", hello)
http.ListenAndServe(":8000", nil)
}