utils

package
v0.1.42 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PermissionAdmin grants all permissions on a team
	PermissionAdmin = authz.AuthzAction("admin")
	// PermissionSuperAdmin grants all permissions
	PermissionSuperAdmin = authz.AuthzAction("superadmin")
	// PermissionCreate grants the ability to create
	PermissionCreate = authz.AuthzAction("create")
	// PermissionDelete grants the ability to delete
	PermissionDelete = authz.AuthzAction("delete")
	// PermissionEdit grants the ability to edit
	PermissionEdit = authz.AuthzAction("edit")
	// PermissionView grants the ability to read
	PermissionView = authz.AuthzAction("view")
)
View Source
const (
	// RoleAdmin grants all permissions on a team
	RoleAdmin = authz.AuthzAction("Admin")
	// RoleSuperAdmin grants all permissions
	RoleSuperAdmin = authz.AuthzAction("Super Admin")
	// RoleOwner grants all permissions
	RoleOwner = authz.AuthzAction("Owner")
	// Editor grants the ability to edit
	RoleEditor = authz.AuthzAction("Editor")
	// RoleViewer grants the ability to read
	RoleViewer = authz.AuthzAction("Viewer")
)

Variables

View Source
var DefaultErrorHandler = func(c *fiber.Ctx, err error) error {
	code := fiber.StatusInternalServerError
	message := err.Error()

	// retrive the custom error code if it's a *fiber.Error
	var e *fiber.Error
	if errors.As(err, &e) {
		code = e.Code
	}

	return c.Status(code).JSON(fiber.Map{"error": message, "code": code})
}

DefaultErrorHandler is the default error handler.

Functions

func CreateNKeyPair

func CreateNKeyPair(p nkeys.PrefixByte) (nkeys.KeyPair, error)

CreateNKeyPair creates a new NKey pair.

func FirstN added in v0.1.17

func FirstN(s string, n int) string

FirstN returns the first n characters of a string.

func IntPtr added in v0.1.15

func IntPtr(i *int) int

IntPtr returns a pointer to an int.

func PrettyByteSize added in v0.1.24

func PrettyByteSize(b float64, size string) int64

PrettyByteSize ...

func PtrInt

func PtrInt(i int) *int

PtrInt returns a pointer to an int.

func PtrStr

func PtrStr(s *string) string

PtrStr returns a pointer to a string.

func PtrTime

func PtrTime(t time.Time) *time.Time

PtrTime returns a pointer to a time.

func PtrUUID

func PtrUUID(u uuid.UUID) *uuid.UUID

PtrUUID returns a pointer to a UUID.

func ShortPubKey added in v0.1.24

func ShortPubKey(pubKey string) string

ShortPubKey returns the first 8 characters of the public key.

func StrPtr

func StrPtr(s string) *string

StrPtr returns a pointer to a string.

func TimePtr

func TimePtr(t *time.Time) time.Time

TimePtr returns a pointer to a time.

func UUIDPtr

func UUIDPtr(u *uuid.UUID) uuid.UUID

UUIDPtr returns a pointer to a UUID.

Types

type ByteSize added in v0.1.24

type ByteSize int64

ByteSize represents the size of a value in bits.

const (
	B  ByteSize = 1
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
)

Jump to

Keyboard shortcuts

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