Module http_helpers

Module http_helpers 

Source
Expand description

HTTP request and response helpers for Sentinel proxy

This module provides utilities for:

  • Extracting request information from Pingora sessions
  • Writing HTTP responses to Pingora sessions
  • Trace ID extraction from headers

These helpers reduce boilerplate in the main proxy logic and ensure consistent handling of HTTP operations.

Functionsยง

extract_request_info
Extract request info from a Pingora session
get_or_create_trace_id
Extract or generate a trace ID from request headers
get_or_create_trace_id_default
Extract or generate a trace ID (convenience function using TinyFlake default)
write_error
Write an error response to a Pingora session
write_json_error
Write a JSON error response
write_response
Write an HTTP response to a Pingora session
write_text_error
Write a plain text error response