From f8ca9165b1dd673a2144da4999a44c32f3ebab48 Mon Sep 17 00:00:00 2001 From: xuyang2 Date: Tue, 2 Jul 2024 20:42:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Add=20go1.22=20"net/http"=20package?= =?UTF-8?q?=E2=80=99s=20router=20#7571?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go/nethttp/config.yaml | 4 ++++ go/nethttp/go.mod | 3 +++ go/nethttp/main.go | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 go/nethttp/config.yaml create mode 100644 go/nethttp/go.mod create mode 100644 go/nethttp/main.go 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) +} From 8a310be175458fc029369c178db658c165aedb7e Mon Sep 17 00:00:00 2001 From: xuyang2 Date: Tue, 2 Jul 2024 21:51:08 +0800 Subject: [PATCH 2/3] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marwan Rabbâa --- go/nethttp/config.yaml | 4 ++-- go/nethttp/go.mod | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/go/nethttp/config.yaml b/go/nethttp/config.yaml index 0e8a2a0f337..535821e3159 100644 --- a/go/nethttp/config.yaml +++ b/go/nethttp/config.yaml @@ -1,4 +1,4 @@ framework: - website: https://go.dev/ + website: go.dev # https://go.dev/blog/routing-enhancements - version: "1.22" + version: 1.22" diff --git a/go/nethttp/go.mod b/go/nethttp/go.mod index 906a5706c7e..922133d9472 100644 --- a/go/nethttp/go.mod +++ b/go/nethttp/go.mod @@ -1,3 +1,2 @@ module main -go 1.22 From b7cfe41f5f448f5d8b26035d315470a9ca8a79c7 Mon Sep 17 00:00:00 2001 From: xuyang2 Date: Tue, 2 Jul 2024 21:55:50 +0800 Subject: [PATCH 3/3] partial revert config.yaml --- go/nethttp/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/nethttp/config.yaml b/go/nethttp/config.yaml index 535821e3159..5c994069925 100644 --- a/go/nethttp/config.yaml +++ b/go/nethttp/config.yaml @@ -1,4 +1,4 @@ framework: website: go.dev # https://go.dev/blog/routing-enhancements - version: 1.22" + version: "1.22"