blob: 88f361f7cab8dc4aee5772e9c39f62414a612925 (
plain)
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
|
package main
import (
"fmt"
"log"
"net/http"
"time"
)
func echo(w http.ResponseWriter, req *http.Request) {
startTime := time.Now()
log.Printf("request recv %v", startTime)
fmt.Fprintf(w, "start time: %v\n", startTime)
for key, value := range req.Header {
for _, v := range value {
fmt.Fprintf(w, "%v: %v\n", key, v)
}
}
endTime := time.Now()
fmt.Fprintf(w, "end time: %v\n", endTime)
}
func main() {
http.HandleFunc("/", echo)
log.Println("...starting echo server...")
http.ListenAndServe(":9000", nil)
}
|