3 ms·
That was my gut feeling as well, but honestly when using Gin, having methods like .Get(), .Post() etc. has never solved anything for me. Having a single registr
by thiht 3y ago
That was my gut feeling as well, but honestly when using Gin, having methods like .Get(), .Post() etc. has never solved anything for me. Having a single registration method with the method in the string is probably 100% fine.
- cowl 3y ago"probably" is key Here. this introduces the possibility of typo erros that can even be discovered late. Now you will need a Vet check to make sure that GET, POST etc are written correctly instead of letting the compiler to do it's job. .Get(), Post() get compiler guarantees that they are sending the right Method string.
- thiht 3y agoI agree on principle, but in practice routers rely on arbitrary strings anyway. I don't see why the verb is not just a part of the route. In my head it's as if we did this: http.Segments("foo", "bar", http.Param("barID"), "baz") instead of: /foo/bar/:barID/baz Is it sliiiightly safer? Yes. Is it insane? Also yes.