Implement a statistics HTTP server

Strikes me that all these methods could be replaced by one generic function, as per my example above...?