extract HTTP handler
big restructuring I