Skip to content

Commit 251edba

Browse files
committed
_content/blog: fix function name in routing post
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]>
1 parent ca874c6 commit 251edba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

_content/blog/routing-enhancements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ has an integer identifier. A request like `GET /posts/234` retrieves the post wi
3535
ID 234. Before Go 1.22, the code for handling those requests would start with a
3636
line like this:
3737

38-
http.Handle("/posts/", handlePost)
38+
http.HandleFunc("/posts/", handlePost)
3939

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

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

49-
http.Handle("GET /posts/{id}", handlePost2)
49+
http.HandleFunc("GET /posts/{id}", handlePost2)
5050

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

0 commit comments

Comments
 (0)