Skip to main content

WSGI middleware to handle HTTP responses using exceptions

Project description

httpexceptor

WSGI middleware to handle HTTP responses using exceptions

provides a group of exception classes representing non-2xx HTTP statuses, along with a WSGI middleware to turn the exceptions into proper HTTP headers

originally extracted from TiddlyWeb

Usage

from httpexceptor import HTTPExceptor, HTTP404

# register middleware
app = HTTPExceptor(app)

# ...

if unavailable:
    raise HTTP404('resource unavailable')

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page