API Tracking

@itsthatguy This should add some tracking for the API requests.

I also reworked some of the webserver stuff: it was nicer to move the tracking to a middleware function, and the  avatar determination to param logic via a `Router`.