ctx

package
v0.0.0-...-ec844c3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ValueKey = CtxKey("ctx.bhe")

Variables

This section is empty.

Functions

func RequestID

func RequestID(request *http.Request) string

RequestID returns the request ID of the HTTP request

func Set

func Set(ctx context.Context, bhCtx *Context) context.Context

Set takes the given golang context and stores the given bh context struct inside it using a well known key

func SetRequestContext

func SetRequestContext(request *http.Request, bhCtx *Context) *http.Request

SetRequestContext sets the given BloodHound Context pointer into the request's context. The resulting, new request pointer is then returned.

Types

type Context

type Context struct {
	StartTime    time.Time
	Timeout      time.Duration
	RequestID    string
	AuthCtx      auth.Context
	Host         *url.URL
	RequestedURL model.AuditableURL
	RequestIP    string
	RemoteAddr   string
}

Context holds contextual data that is passed around to functions. This is an extension to Golang's built in context.

func FromRequest

func FromRequest(request *http.Request) *Context

FromRequest extracts the Golang-builtin-Context from a request and converts it to a BloodHound Context struct

func Get

func Get(ctx context.Context) *Context

Get converts a Golang-builtin-Context into a BloodHound-defined Context struct

func (*Context) ConstructGoContext

func (s *Context) ConstructGoContext() context.Context

func (*Context) WithHost

func (s *Context) WithHost(host *url.URL) *Context

func (*Context) WithRequestID

func (s *Context) WithRequestID(requestID string) *Context

WithRequestID adds the supplied RequestID value to the BloodHound Context structure

func (*Context) WithUserSession

func (s *Context) WithUserSession(userSession auth.Context) *Context

WithUserSession adds the supplied AuthCtx value to the BloodHound Context structure

type CtxKey

type CtxKey string

Use our own type rather than a primitive to avoid collisions (https://staticcheck.io/docs/checks#SA1029)

Jump to

Keyboard shortcuts

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