Hacker News new | ask | show | jobs
by oppositelock 3090 days ago
It's a nice reference program to show you what's going on.

I build stuff like this for a living. I'd recommend not re-inventing the wheel yourself and using a nice web framework, like Echo (https://github.com/labstack/echo) or Gin (https://github.com/gin-gonic/gin). I prefer Echo due to a cleaner, mockable design, but they're equivalent.

You can throw up that web server in 1/10 the code to do the same thing, and using built-in middleware is less work than writing your own.

2 comments

I also build stuff like this for a living and I tend to avoid frameworks :)

I don't care for Gin. I'll take a look at Echo.

I tend to agree and I’d throw Chi in the mix. I like Chi quite a bit. Or, use the Gorilla components and middleware.
I also use Chi a lot and Chi and this example are actually complimentary: you can take the Chi router and pass it to an http.Server in the handler attribute to make it work.