Skip to content

Commit

Permalink
Add go1.22 "net/http" package’s router the-benchmarker#7571
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyang2 committed Jul 2, 2024
1 parent bade2fd commit f8ca916
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go/nethttp/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
website: https://go.dev/
# https://go.dev/blog/routing-enhancements
version: "1.22"
3 changes: 3 additions & 0 deletions go/nethttp/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module main

go 1.22
24 changes: 24 additions & 0 deletions go/nethttp/main.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit f8ca916

Please sign in to comment.