15 lines
446 B
Python
15 lines
446 B
Python
"""Shared HTTP status-code bucketing — used by the aggregator (per-IP
|
|
rollup) and available for any endpoint needing the same 2xx/3xx/4xx/5xx
|
|
buckets, so there's one bucketing rule, not several copies."""
|
|
from __future__ import annotations
|
|
|
|
|
|
def status_bucket(status_code: int) -> str:
|
|
if status_code < 300:
|
|
return "2xx"
|
|
if status_code < 400:
|
|
return "3xx"
|
|
if status_code < 500:
|
|
return "4xx"
|
|
return "5xx"
|