diff --git a/go/nethttp/config.yaml b/go/nethttp/config.yaml new file mode 100644 index 00000000000..0e8a2a0f337 --- /dev/null +++ b/go/nethttp/config.yaml @@ -0,0 +1,4 @@ +framework: + website: https://go.dev/ + # https://go.dev/blog/routing-enhancements + version: "1.22" diff --git a/go/nethttp/go.mod b/go/nethttp/go.mod new file mode 100644 index 00000000000..906a5706c7e --- /dev/null +++ b/go/nethttp/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.22 diff --git a/go/nethttp/main.go b/go/nethttp/main.go new file mode 100644 index 00000000000..ecad704884d --- /dev/null +++ b/go/nethttp/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "net/http" +) + +func main() { + mux := http.NewServeMux() + + mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("")) + }) + + mux.HandleFunc("GET /user/{name}", func(w http.ResponseWriter, r *http.Request) { + name := r.PathValue("name") + w.Write([]byte(name)) + }) + + mux.HandleFunc("POST /user", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("")) + }) + + http.ListenAndServe(":3000", mux) +}