From 00361743d5c89787c207bd95a88ba22130ae172b Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Tue, 19 Dec 2023 20:51:52 -0800 Subject: [PATCH] basic echo server example --- recount-server.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/recount-server.go b/recount-server.go index 6dce2c7..3c938ff 100644 --- a/recount-server.go +++ b/recount-server.go @@ -3,11 +3,31 @@ package main import ( "fmt" "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() { log.SetPrefix("RecountServer: ") log.SetFlags(0) - fmt.Println("Hello World") + http.HandleFunc("/hello", hello) + http.HandleFunc("/headers", headers) + + http.ListenAndServe(":8090", nil) + + //fmt.Println("Hello World") }