News for hackers. Stuff that matters.
Re:Better HTTP server routing in Go 1.22 by oppositelock on Monday October 16, 2023 @10:17AM (#37900180)
The panics are really annoying. Sometimes, you generate routes dynamically from some data, and it would be nice for this to be an error, so you can handle it yourself and decide to skip a route, or let the user know.

With the panic, I have to write some spaghetti code with a recover in a goroutine.

Re:Better HTTP server routing in Go 1.22 by velcrovan on Monday October 16, 2023 @11:07AM (#37900855)
What kinds of routes would you generate dynamically that couldn't be implemented as wildcards in the match pattern? Genuine question
Re:Better HTTP server routing in Go 1.22 by cowl on Monday October 16, 2023 @07:37PM (#37908144)
> or let the user know

Many are misunderstanding when the panic happens. It does not happen when the user requests the path, it happens when the path is registered. The user will never arrive at that path to be notified. You will be notified that you have a logic error at the application startup. It can be caught by the simplest of tests before you deploy your application.

Re:Better HTTP server routing in Go 1.22 by kunley on Tuesday October 17, 2023 @11:44AM (#37916906)
Mmmm, code with recover is just a valid code. Calling it spaghetti seems unjustified.