Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interesting. Now that the mux can match methods, I wonder what happens when you match a route but not a method. Do you get a 404, or a 405?

Apparently, a 405 with a properly-populated Allow header.

https://cs.opensource.google/go/go/+/master:src/net/http/ser...

I know people don't love the stringly-typed interface, but rather than typo the HTTP method name, I suspect I'm more likely to simply type the wrong thing in correctly anyways. So I'd be fine with having static analysis warn about bad syntax personally.

For what it's worth, though, in my opinion, you probably shouldn't use the default serve mux if you already have advanced needs; there are plenty of options out there that are more suitable to different use cases, and if you're already doing dynamic route generation, it may wind up being less effort to just write your own router rather than try to munge whatever data structures you have into an existing router's.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: