Skip to content

Commit

Permalink
Add Http server spike
Browse files Browse the repository at this point in the history
  • Loading branch information
regiluze committed Sep 27, 2018
1 parent 81c8576 commit 1631ba0
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,30 @@ import (

func main() {
address := flag.String("address", "0.0.0.0", "Listen address")
port := flag.String("port", "18080", "Listen port")
port := flag.String("port", "18081", "Listen port")
flag.Parse()

addressAndPort := fmt.Sprintf("%s:%s", *address, *port)
log.Println("Starting HTTP server at ", addressAndPort)
http.HandleFunc("/kk", func(w http.ResponseWriter, r *http.Request) {
log.Println("Starting HTTP server at >>>>> ", addressAndPort)

http.HandleFunc("/spycommand/reset", func(w http.ResponseWriter, r *http.Request) {
if r.Method == "PUT" {
// reset requestsHub
for key, value := range r.URL.Body() {
fmt.Println("\n param name:", key, "param value:", value)
}
}
})
http.HandleFunc("/spycommand/verify", func(w http.ResponseWriter, r *http.Request) {
// Parameters --> path and method
if r.Method == "GET" {
// find from requestsHub
for key, value := range r.URL.Query() {
fmt.Println("\n param name:", key, "param value:", value)
}
}
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Printf(">>>>>> hello path: %q method: %q ", html.EscapeString(r.URL.Path), r.Method)
for key, value := range r.URL.Query() {
fmt.Println("\n k:", key, "v:", value)
Expand Down

0 comments on commit 1631ba0

Please sign in to comment.