seperated Web and API version of middleware. API version middleware will return HTTP status codes in case of something wrong whereas the web version will redirect the user