httpx

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package httpx provides standard-library HTTP response and path primitives. It contains no authentication, logging, telemetry or transport construction; structured API error handling stays in apikit.

Index

Constants

View Source
const RequestIDHeader = "X-Request-Id"

RequestIDHeader is the request identifier carried on every API call.

Variables

This section is empty.

Functions

func ContextWithRequestID

func ContextWithRequestID(ctx context.Context, id string) context.Context

ContextWithRequestID returns a context that carries a validated request id. An id that fails ValidRequestID is not stored.

func NormalizePublicAPIPath

func NormalizePublicAPIPath(path string) string

NormalizePublicAPIPath strips the public API version prefix so handlers can match on /runtime/... paths whether the request arrived as /api/v1/runtime/* or legacy /api/runtime/*.

func RequestID

func RequestID(ctx context.Context) string

RequestID returns the validated request id stored in ctx, or "" when absent.

func ValidRequestID

func ValidRequestID(id string) bool

ValidRequestID reports whether id is safe to echo, log, and store.

func ValidTraceID

func ValidTraceID(id string) bool

ValidTraceID reports whether id is a W3C trace id: 32 lowercase hex digits, not all zero.

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, payload any)

WriteJSON writes a JSON response with the specified status code. It sets appropriate Content-Type headers and handles JSON marshaling errors. It first marshals the payload to check for encoding errors before writing headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL