forked from didi/sharingan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (31 loc) · 754 Bytes
/
main.go
File metadata and controls
37 lines (31 loc) · 754 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
31
32
33
34
35
36
37
// Replayer demo for how to import package "github.com/didi/sharingan/replayer"
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
// Here to import package
_ "github.com/didi/sharingan"
// TODO:Attention please! 最后import其他业务包!
)
func main() {
http.HandleFunc("/", indexHandle)
log.Fatal(http.ListenAndServe(":9999", nil))
}
func indexHandle(w http.ResponseWriter, r *http.Request) {
testHTTPRequest()
fmt.Fprintf(w, "Hello world!\n")
}
func testHTTPRequest() {
rsp, err := http.Get("http://127.0.0.1:8888")
if err != nil {
fmt.Printf("[testHTTPRequest][err:%v]\n", err)
return
}
defer rsp.Body.Close()
body, err := ioutil.ReadAll(rsp.Body)
if err != nil {
fmt.Println("res:", string(body), err)
}
}