utilities

package
v0.0.0-...-e3e9b0f Latest Latest
Warning

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

Go to latest
Published: Mar 29, 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 IsRedirectURLValid

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

func SafeClose

func SafeClose(closer io.Closer)

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