Skip to content

Commit

Permalink
_content/blog: fix function name in routing post
Browse files Browse the repository at this point in the history
Fixes golang/go#66199.

Change-Id: I8a502d3e97631809409b757abcac412ba9213833
Reviewed-on: https://go-review.googlesource.com/c/website/+/571275
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Eli Bendersky <[email protected]>
  • Loading branch information
jba committed Mar 13, 2024
1 parent ca874c6 commit 251edba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _content/blog/routing-enhancements.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ has an integer identifier. A request like `GET /posts/234` retrieves the post wi
ID 234. Before Go 1.22, the code for handling those requests would start with a
line like this:

http.Handle("/posts/", handlePost)
http.HandleFunc("/posts/", handlePost)

The trailing slash routes all requests beginning `/posts/` to the `handlePost`
function, which would have to check that the HTTP method was GET, extract
Expand All @@ -46,7 +46,7 @@ is surprising at the least.

In Go 1.22, the existing code will continue to work, or you could instead write this:

http.Handle("GET /posts/{id}", handlePost2)
http.HandleFunc("GET /posts/{id}", handlePost2)

This pattern matches a GET request whose path begins "/posts/" and has two
segments. (As a special case, GET also matches HEAD; all the other methods match
Expand Down

0 comments on commit 251edba

Please sign in to comment.