stdlib only with upcoming 1.22 which isn't yet released, see 
https://eli.thegreenplace.net/2023/better-http-server-routing-in-go-122/

gorilla mux is another 3rd party muxer with variable support 
https://github.com/gorilla/mux

the "best" way using only stdlib mux is to parse the path and extract the 
variable yourself. otherwise, wait for 1.22. or use an existing 3rd party 
module.

On Thursday, October 19, 2023 at 1:27:59 PM UTC+2 Dejan Duh wrote:

> Hi everyone. I'm building an api with net/http and I'm having trouble 
> with url variables. How can I get the url variables form the url in the 
> REST way. Example, if I have a url like "http:/localhost:3000/users/:id". 
> I want to get the user with the id given from the url. What is the best 
> way to get the id using only the standart lib? Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9b1030a6-1bc3-4b60-8e99-d98cd760beddn%40googlegroups.com.

Reply via email to