Documentation ¶
Index ¶
- func CombinedContext(signals ...interface{}) (context.Context, context.CancelFunc)
- func ContextFromChan(chStop <-chan struct{}) (context.Context, context.CancelFunc)
- func CopyFileWithMaxPerms(srcPath, dstPath string, perms os.FileMode) error
- func DeepCopyJSValue(val interface{}) interface{}
- func DeviceIDFromX509Pubkey(pubkey interface{}) string
- func EnsureDirAndMaxPerms(path string, perms os.FileMode) error
- func EnsureFileMaxPerms(file *os.File, perms os.FileMode) error
- func EnsureFilepathMaxPerms(filepath string, perms os.FileMode) error
- func Filter[T any](in []T, fn func(T) bool) []T
- func FilterEmptyBytes(bss [][]byte) [][]byte
- func FilterEmptyStrings(s []string) []string
- func GetValue(x interface{}, keypath []string) (interface{}, bool)
- func GuessContentTypeFromFilename(filename string) string
- func IsLocalStateURI(stateURI string) bool
- func MakeSelfSignedX509Certificate() (*tls.Certificate, error)
- func Map[InType any, OutType any](in []InType, fn func(InType) OutType) []OutType
- func ParseJWT(authHeader string, jwtSecret []byte) (jwt.MapClaims, bool, error)
- func PrettyJSON(x interface{}) string
- func PrintfDebugPrinter(msg string, args ...interface{})
- func RandomBytes(length int) []byte
- func RandomNumberString() string
- func RandomString(n int) string
- func RespondJSON(resp http.ResponseWriter, data interface{})
- func SniffContentType(filename string, data io.ReadCloser) (io.ReadCloser, string, error)
- func TrimStringToLen(s string, length int) string
- func UnmarshalHTTPRequest(into interface{}, r *http.Request) error
- func UnmarshalHTTPResponse(into interface{}, r *http.Response) error
- func UnrestrictedCors(handler http.Handler) http.Handler
- func WriteFileWithMaxPerms(path string, data []byte, perms os.FileMode) error
- type ChanContext
- type ExponentialBackoff
- type ExponentialBackoffTicker
- type FileSize
- type HTTPClient
- type HTTPHeaderUnmarshaler
- type Mailbox
- type StaticTicker
- type Ticker
- type URLPathUnmarshaler
- type WaitGroupChan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombinedContext ¶
func CombinedContext(signals ...interface{}) (context.Context, context.CancelFunc)
CombinedContext creates a context that finishes when any of the provided signals finish. A signal can be a `context.Context`, a `chan struct{}`, or a `time.Duration` (which is transformed into a `context.WithTimeout`).
func ContextFromChan ¶
func ContextFromChan(chStop <-chan struct{}) (context.Context, context.CancelFunc)
ContextFromChan creates a context that finishes when the provided channel receives or is closed.
func CopyFileWithMaxPerms ¶
CopyFileWithMaxPerms copies the file at `srcPath` to `dstPath` and ensures that it has permissions that are no more permissive than the given ones.
func DeepCopyJSValue ¶
func DeepCopyJSValue(val interface{}) interface{}
@@TODO: everything about this is horrible
func DeviceIDFromX509Pubkey ¶
func DeviceIDFromX509Pubkey(pubkey interface{}) string
func EnsureDirAndMaxPerms ¶
EnsureDirAndMaxPerms ensures that the given path exists, that it's a directory, and that it has permissions that are no more permissive than the given ones.
- If the path does not exist, it is created - If the path exists, but is not a directory, an error is returned - If the path exists, and is a directory, but has the wrong perms, it is chmod'ed
func EnsureFileMaxPerms ¶
EnsureFileMaxPerms ensures that the given file has permissions that are no more permissive than the given ones.
func EnsureFilepathMaxPerms ¶
EnsureFilepathMaxPerms ensures that the file at the given filepath has permissions that are no more permissive than the given ones.
func FilterEmptyBytes ¶
func FilterEmptyStrings ¶
func IsLocalStateURI ¶
func MakeSelfSignedX509Certificate ¶
func MakeSelfSignedX509Certificate() (*tls.Certificate, error)
func PrettyJSON ¶
func PrettyJSON(x interface{}) string
func PrintfDebugPrinter ¶
func PrintfDebugPrinter(msg string, args ...interface{})
func RandomBytes ¶
func RandomNumberString ¶
func RandomNumberString() string
func RandomString ¶
func RespondJSON ¶
func RespondJSON(resp http.ResponseWriter, data interface{})
func SniffContentType ¶
func SniffContentType(filename string, data io.ReadCloser) (io.ReadCloser, string, error)
func TrimStringToLen ¶
func UnmarshalHTTPRequest ¶
func UnmarshalHTTPResponse ¶
Types ¶
type ChanContext ¶
type ChanContext chan struct{}
func (ChanContext) Done ¶
func (ch ChanContext) Done() <-chan struct{}
func (ChanContext) Err ¶
func (ch ChanContext) Err() error
func (ChanContext) Value ¶
func (ch ChanContext) Value(key interface{}) interface{}
type ExponentialBackoff ¶
type ExponentialBackoff struct { Min time.Duration Max time.Duration // contains filtered or unexported fields }
func (*ExponentialBackoff) Next ¶
func (eb *ExponentialBackoff) Next() time.Duration
func (*ExponentialBackoff) Ready ¶
func (eb *ExponentialBackoff) Ready() (ready bool, until time.Duration)
func (*ExponentialBackoff) Reset ¶
func (eb *ExponentialBackoff) Reset()
func (*ExponentialBackoff) Wait ¶
func (eb *ExponentialBackoff) Wait()
type ExponentialBackoffTicker ¶
type ExponentialBackoffTicker struct {
// contains filtered or unexported fields
}
func NewExponentialBackoffTicker ¶
func NewExponentialBackoffTicker(min, max time.Duration) *ExponentialBackoffTicker
func (*ExponentialBackoffTicker) Close ¶
func (t *ExponentialBackoffTicker) Close()
func (*ExponentialBackoffTicker) Notify ¶
func (t *ExponentialBackoffTicker) Notify() <-chan time.Time
func (*ExponentialBackoffTicker) Reset ¶
func (t *ExponentialBackoffTicker) Reset()
func (*ExponentialBackoffTicker) Start ¶
func (t *ExponentialBackoffTicker) Start()
type FileSize ¶
type FileSize uint64
func ParseFileSize ¶
func (FileSize) MarshalText ¶
func (*FileSize) UnmarshalText ¶
type HTTPClient ¶
func MakeHTTPClient ¶
func MakeHTTPClient(requestTimeout, reapIdleConnsInterval time.Duration, cookieJar http.CookieJar, tlsCerts []tls.Certificate) *HTTPClient
func (HTTPClient) Close ¶
func (c HTTPClient) Close()
type HTTPHeaderUnmarshaler ¶
type Mailbox ¶
type Mailbox[T any] struct { // contains filtered or unexported fields }
func NewMailbox ¶
func (*Mailbox[T]) RetrieveAll ¶
func (m *Mailbox[T]) RetrieveAll() []T
type StaticTicker ¶
type StaticTicker struct {
// contains filtered or unexported fields
}
func NewStaticTicker ¶
func NewStaticTicker(interval time.Duration) StaticTicker
func (StaticTicker) Close ¶
func (t StaticTicker) Close()
func (StaticTicker) Notify ¶
func (t StaticTicker) Notify() <-chan time.Time
func (StaticTicker) Start ¶
func (t StaticTicker) Start()
type URLPathUnmarshaler ¶
type WaitGroupChan ¶
type WaitGroupChan struct {
// contains filtered or unexported fields
}
WaitGroupChan creates a channel that closes when the provided sync.WaitGroup is done.
func NewWaitGroupChan ¶
func NewWaitGroupChan(ctx context.Context) *WaitGroupChan
func (*WaitGroupChan) Add ¶
func (wg *WaitGroupChan) Add(i int)
func (*WaitGroupChan) Close ¶
func (wg *WaitGroupChan) Close()
func (*WaitGroupChan) Done ¶
func (wg *WaitGroupChan) Done()
func (*WaitGroupChan) Wait ¶
func (wg *WaitGroupChan) Wait() <-chan struct{}