Complete working HTTP server example

In one of the very earliest go language talks, Rob Pike shows an example of a “robust and performant” HTTP server in about 10 lines of go. It was cute, but I was never sure it was realistic. It looked to me to handle the webAPI-type functions, but didn’t to basic file contents delivery.

Is there a modern, more complete version of an HTTP server written for a recent or current release of go? I’d love a link…


Well, http.ServeFile makes serving static content very easy:

You might also be interested in this fun guide:

Or maybe this:

You’re right, the 10-line HTTP server from Rob Pike’s early Go talk was a simplified example and not meant for real-world production use. However, there are definitely modern, more complete versions of HTTP servers written in Go that offer both web API functionality and file content delivery.

Yes, ideally, I’d find a 30 or so line example that can do both some web API and boring old content delivery. Back at the turn of the century, we’d often do Java servlets in a Java layer, but just dispatch boring content delivery to Apache or some equivalent. I’d rather stay pure idiomatic go.

I’ve love a link to a suitable example?

Than you for the information.