I Have a small http server
http.HandleFunc("/", router.Root)
http.HandleFunc("/post", router.Post)
http.HandleFunc("/post/{id}", router.PostRet)
http.ListenAndServe(":8080", nil)
why when I send a request to localhost:8080/post/2 the answer is from “/” root handler??? and when I write “/post/{id}” should the request url be something like “localhost:8080/post/?id=222” ?
1 Like
NobbZ
(Norbert Melzer)
October 6, 2019, 9:45am
2
What server/muxer are you using? I can not find that syntax in the defaults documentation.
1 Like
NobbZ
(Norbert Melzer)
October 6, 2019, 9:53am
4
And that doesn’t support that syntax, you are adding a handler for /post/{id}
literally. Try exactly that URL in your browser…
1 Like
So you suggest using external libraries like gorilla mux ?
1 Like
NobbZ
(Norbert Melzer)
October 6, 2019, 9:55am
6
Either that, or using regular query parameters. Or implementing a muxer on your own that can handle that.
2 Likes
system
(system)
Closed
January 4, 2020, 10:04am
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.