Split out Common and Snap modules

Move the Snap-specific code to a single module, to allow backends
using other webservers.