utilities

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version string

Version is git commit or release tag from which this binary was built.

Functions

func GetBodyBytes

func GetBodyBytes(req *http.Request) ([]byte, error)

GetBodyBytes reads the whole request body properly into a byte array.

func GetIPAddress

func GetIPAddress(r *http.Request) string

GetIPAddress returns the real IP address of the HTTP request. It parses the X-Forwarded-For header.

func GetReferrer

func GetReferrer(r *http.Request, config *conf.GlobalConfiguration) string

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID reads the request ID from the context.

func IsRedirectURLValid

func IsRedirectURLValid(config *conf.GlobalConfiguration, redirectURL string) bool

func SafeClose

func SafeClose(closer io.Closer)

func WaitForCleanup

func WaitForCleanup(ctx context.Context, wg *sync.WaitGroup)

WaitForCleanup waits until all long-running goroutines shut down cleanly or until the provided context signals done.

func WithRequestID

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

WithRequestID adds the provided request ID to the context.

Types

type HIBPBloomCache

type HIBPBloomCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewHIBPBloomCache

func NewHIBPBloomCache(n uint, fp float64) *HIBPBloomCache

func (*HIBPBloomCache) Add

func (c *HIBPBloomCache) Add(ctx context.Context, prefix []byte, suffixes [][]byte) error

func (*HIBPBloomCache) Cap

func (c *HIBPBloomCache) Cap() uint

func (*HIBPBloomCache) Contains

func (c *HIBPBloomCache) Contains(ctx context.Context, prefix, suffix []byte) (bool, error)

type PostgresError

type PostgresError struct {
	Code           string `json:"code"`
	HttpStatusCode int    `json:"-"`
	Message        string `json:"message"`
	Hint           string `json:"hint,omitempty"`
	Detail         string `json:"detail,omitempty"`
}

PostgresError is a custom error struct for marshalling Postgres errors to JSON.

func NewPostgresError

func NewPostgresError(err error) *PostgresError

NewPostgresError returns a new PostgresError if the error was from a publicly accessible Postgres error.

func (*PostgresError) IsUniqueConstraintViolated

func (pg *PostgresError) IsUniqueConstraintViolated() bool

Jump to

Keyboard shortcuts

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