internal/v4: implement stats endpoint

internal/v4/stats.go and internal/v4/stats_test.go are directly derived from
code in _old, although simplified to return only JSON-formatted results.

This required a fair number of fixes to other code, which
unfortunately aren't that easy to pick apart now, including the
following:

- internal/charmstore: make stats counter tests less hacky.

Because the internal/v4 tests are outside charmstore, delving
directly into the database to tweak the time stamps seemed unwarranted,
so added IncCounterAtTime and changed internal/v4 tests and existing
internal/charmstore tests to use it.

- internal/charmstore: move mongojs condition into storetesting.

This avoids duplicating the logic to determine whether tests requiring
mongodb embedded javascript can be run.

- internal/router: universal ParseForm.

This clears up responsibility for who should call ParseForm.

- internal/router: strip prefix from global handlers

This makes the global handlers (including /stats/counters) consistent
with other handlers in router.Handlers.

- internal/router: add ServeMux, NotFoundHandler

The original /stats/counter tests tested http status of paths which previously
returned an http.StatusNotFound status but with a non-JSON body.
The above two handlers make the not-found pages consistent
with the rest of the API.

- params: add ErrForbidden, ErrBadRequest

The original /stats/counter tests tested for statuses which our
current code was incapable of generating. The above two
errors make it capable.
Unfortunately, most machines' router tables do not special-case either of the above two ranges, so they don't help to guard against accidental network access from tests. 0.1.2.3, on the other hand is (at least on Linux) picked up immediately by the network stack as an invalid IP address, and generates an error without touching the network.

That's why we use 0.1.2.3 (or similar) as a testing IP address in juju-core too.