File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ has an integer identifier. A request like `GET /posts/234` retrieves the post wi
35
35
ID 234. Before Go 1.22, the code for handling those requests would start with a
36
36
line like this:
37
37
38
- http.Handle ("/posts/", handlePost)
38
+ http.HandleFunc ("/posts/", handlePost)
39
39
40
40
The trailing slash routes all requests beginning ` /posts/ ` to the ` handlePost `
41
41
function, which would have to check that the HTTP method was GET, extract
@@ -46,7 +46,7 @@ is surprising at the least.
46
46
47
47
In Go 1.22, the existing code will continue to work, or you could instead write this:
48
48
49
- http.Handle ("GET /posts/{id}", handlePost2)
49
+ http.HandleFunc ("GET /posts/{id}", handlePost2)
50
50
51
51
This pattern matches a GET request whose path begins "/posts/" and has two
52
52
segments. (As a special case, GET also matches HEAD; all the other methods match
You can’t perform that action at this time.
0 commit comments