refactor with http-errors

cc @eivindfjeldstad @jonathanong 
how so?