reqid

package
v0.2.0-dev.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package reqid is the short request id the admin HTTP server stamps on every request: in the context, the log records, the audit rows and, once the caller is signed in, the X-Request-Id response header. It lets a person who sees "request code abc123" in the panel and an operator reading the logs talk about the same request. The id is random and only names the request; it is never a credential, and an id sent by the client is not used.

The header is written only after the session or token middleware accepted the caller (MarkAuthed): an unauthenticated probe of the admin address must see what it sees on the decoy, and a header only the admin sends would tell it where the admin is.

Index

Constants

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

Header is the response header that carries the id.

Variables

This section is empty.

Functions

func From

func From(ctx context.Context) string

From returns the id of ctx, or "".

func MarkAuthed

func MarkAuthed(ctx context.Context)

MarkAuthed records that the caller of ctx's request was accepted, so the response may carry the header.

func New

func New() string

New returns a fresh id: 8 lower-case hex characters.

func With

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

With returns ctx carrying a new Request with the given id.

Types

type Request

type Request struct {
	ID string
	// contains filtered or unexported fields
}

Request is the id of one request and whether its caller was accepted.

func Start

func Start(ctx context.Context, id string) (context.Context, *Request)

Start returns ctx carrying a new Request with the given id, and the Request.

func (*Request) Authed

func (r *Request) Authed() bool

Authed reports whether the session or token middleware accepted the caller of the request.

Jump to

Keyboard shortcuts

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