httpx

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package httpx holds tiny echo-boundary helpers shared by both HTTP shells and by handlers. Keep it dependency-light — echo, plus internal/logger, which imports no package from this repository and so cannot close a cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequestID added in v0.21.0

func NewRequestID() string

NewRequestID returns a fresh request id from the generator echo's RequestID middleware uses, so the id of a unit of work that did not arrive over HTTP, such as an IM message, has the same form as the id of one that did.

func RequestID

func RequestID(c echo.Context) string

RequestID returns the request id assigned by the RequestID middleware (response header), falling back to a client-provided header. Empty when neither exists — callers should treat it as optional metadata.

func RequestIDContext added in v0.21.0

func RequestIDContext(next echo.HandlerFunc) echo.HandlerFunc

RequestIDContext carries the request id into the request's context.Context, so that anything logging during the request reports it.

Without this the id exists only on the echo.Context and the response header. It reaches the client — error responses carry it as request_id — and it reaches the access log line, but nothing a handler or a service logs while serving the request can include it. An id a user quotes back therefore names a request whose actual work cannot be found.

Install it directly after middleware.RequestID, which is what assigns the id.

func SafeRequestLogURI added in v0.21.0

func SafeRequestLogURI(u *url.URL, fallback string) string

SafeRequestLogURI renders a request URI for an access log line: the path, never the query string.

Some URLs authorise with a token in the query string, so a log line that keeps the query publishes credentials to anything that reads logs. Dropping it for every request rather than for the paths known to carry one means a new such path cannot arrive unnoticed.

This lives here rather than next to one server's middleware because both HTTP shells need it. A sanitizer that only one of them uses is the worst of the three possible states: the tokens still reach a log, and the shell that redacts them suggests otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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