diff --git a/go/study/ch06_http/go.mod b/go/study/ch06_http/go.mod new file mode 100644 index 00000000..ff334f72 --- /dev/null +++ b/go/study/ch06_http/go.mod @@ -0,0 +1,3 @@ +module github.com/tecyokomichi/WebAppLearning/go/base/ch06_http + +go 1.19 diff --git a/go/study/ch06_http/main.go b/go/study/ch06_http/main.go new file mode 100644 index 00000000..2230f427 --- /dev/null +++ b/go/study/ch06_http/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "io" + "log" + "net/http" +) + +func main() { + // Hello world, the web server + + helloHandler := func(w http.ResponseWriter, req *http.Request) { + io.WriteString(w, "Hello, world!\n") + } + + http.HandleFunc("/hello", helloHandler) + log.Fatal(http.ListenAndServe(":8080", nil)) +}