From fa672683b5cd977e4d5946063acceef3ae2bc0a0 Mon Sep 17 00:00:00 2001 From: arpit12377 <37467879+arpit12377@users.noreply.github.com> Date: Sat, 17 Mar 2018 12:50:08 +0530 Subject: [PATCH] Create task3 --- task3 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 task3 diff --git a/task3 b/task3 new file mode 100644 index 0000000..41a0bd1 --- /dev/null +++ b/task3 @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "net/http" + "strings" + "log" +) + +func sayhelloName(w http.ResponseWriter, r *http.Request) { + r.ParseForm() // parse arguments, you have to call this by yourself + fmt.Println(r.Form) // print form information in server side + fmt.Println("path", r.URL.Path) + fmt.Println("scheme", r.URL.Scheme) + fmt.Println(r.Form["url_long"]) + for k, v := range r.Form { + fmt.Println("key:", k) + fmt.Println("val:", strings.Join(v, "")) + } + fmt.Fprintf(w, "Hello astaxie!") // send data to client side +} + +func main() { + http.HandleFunc("/", sayhelloName) // set router + err := http.ListenAndServe(":9090", nil) // set listen port + if err != nil { + log.Fatal("ListenAndServe: ", err) + } +}