I still think it would not be good, though. For me ‘Handle’ sounds like an instruction to do something, but it only adds/registers a handler.
Also, why require multiple calls to, essentially, pass a set of (pattern, handler) pairs? I think I would have chosen to make a single call “here are the patterns to register and their handlers”. Most tools would have to make only one such call.
It possibly also could be more efficient because the API wouldn’t have to have intermediate states where it can handle one type of request, than 2, 3, etc.
Why keep {id}, then? Why not remove the string processing entirely? You may mistype it. You lose better autocomplete. Seems like there is room for significant improvement, not just a minor change. To which there is still an opportunity to introduce a another API, so it's worth finding it.
“In Go 1.22, the existing code will continue to work, or you could instead write this:
”Can anybody explain why they chose such a stringified approach for the API and not
or, if they don’t want to restrict the set of http verbs, ? I think either would be a better API.