basic echo server example
This commit is contained in:
parent
3a2743cada
commit
00361743d5
1 changed files with 21 additions and 1 deletions
|
@ -3,11 +3,31 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
//"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func hello(w http.ResponseWriter, req *http.Request) {
|
||||||
|
fmt.Fprintf(w, "hello\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func headers(w http.ResponseWriter, req *http.Request) {
|
||||||
|
for name, headers := range req.Header {
|
||||||
|
for _, h := range headers {
|
||||||
|
fmt.Fprintf(w, "%v: %v\n", name, h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetPrefix("RecountServer: ")
|
log.SetPrefix("RecountServer: ")
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
|
||||||
fmt.Println("Hello World")
|
http.HandleFunc("/hello", hello)
|
||||||
|
http.HandleFunc("/headers", headers)
|
||||||
|
|
||||||
|
http.ListenAndServe(":8090", nil)
|
||||||
|
|
||||||
|
//fmt.Println("Hello World")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue