Permalink
Browse files

Fix logs

  • Loading branch information...
rosylilly committed Oct 31, 2015
1 parent e2e3fc2 commit 6a9ec52145b7693924e00c8665602e93eaccb1e9
Showing with 5 additions and 13 deletions.
  1. +5 −13 5f/webapp/golang/proxy.go
View
@@ -59,19 +59,18 @@ func main() {
http2.VerboseLogs = true
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- fmt.Println("りくえすときた")
_, res := getResponse(r)
if res == nil {
- fmt.Println("もうなんもかんもだめ")
+ log.Printf("!!! Request Failed : Can't success request !!!")
http.Error(w, "だめです", 500)
return
}
defer res.Body.Close()
bytes, err := ioutil.ReadAll(res.Body)
if err != nil {
- fmt.Println("ぼでぃよめなかった")
+ log.Printf("!!! Request Failed : Can't read body !!!")
http.Error(w, "だめです", 500)
return
}
@@ -84,15 +83,10 @@ func main() {
w.Header().Set("Content-Type", "application/json")
- fmt.Println("へっだいれた")
-
w.WriteHeader(res.StatusCode)
- fmt.Println("レスポンスこーどおいた")
-
- fmt.Println("%s", bytes)
w.Write(bytes)
- fmt.Println("おわった")
+ log.Printf("%s : %s", res.Status, req.URL.String())
})
http.ListenAndServe(":9293", nil)
@@ -102,8 +96,8 @@ func getResponse(req *http.Request) (*http.Request, *http.Response) {
endpoint := ENDPOINTS[req.URL.Path]
req.URL.Host = endpoint
req.URL.Scheme = "https"
- fmt.Printf("%s\n", req.URL.String())
- fmt.Printf("%s\n", req.Header.Get("X-Perfect-Security-Token"))
+ log.Printf("Request: %s", req.URL.String())
+ log.Printf("Security Token: %s", req.Header.Get("X-Perfect-Security-Token"))
nreq, err := http.NewRequest("GET", req.URL.String(), nil)
if err != nil {
@@ -122,8 +116,6 @@ func getResponse(req *http.Request) (*http.Request, *http.Response) {
return nreq, nil
}
- fmt.Println("りくえすとできた")
-
return nreq, resp
}

0 comments on commit 6a9ec52

Please sign in to comment.