riposo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Overview

Package riposo contains the basic necessities.

Index

Constants

View Source
const (
	// Version references the code version.
	Version = "0.1.0"

	// APIVersion references the implemented API version.
	APIVersion = "1.22"
)
View Source
const (
	Everyone      = "system.Everyone"
	Authenticated = "system.Authenticated"
)

Static principals.

Variables

View Source
var Logger = log.New(os.Stdout, "", log.LstdFlags)

Logger is the default logger for riposo.

Functions

func ParseEnv

func ParseEnv(config interface{}) error

ParseEnv uses github.com/kelseyhightower/envconfig to process RIPOSO_* env variables and parse the values into target config.

Types

type Epoch

type Epoch int64

Epoch is the number of milliseconds since 1970.

func CurrentEpoch

func CurrentEpoch() Epoch

CurrentEpoch returns the current epoch.

func EpochFromTime

func EpochFromTime(t time.Time) Epoch

EpochFromTime creates an epoch from time.

func (Epoch) ETag

func (e Epoch) ETag() string

ETag returns a http.Header compatible ETag value.

func (Epoch) HTTPFormat

func (e Epoch) HTTPFormat() string

HTTPFormat returns a http.Header compatible time string.

func (Epoch) IsZero

func (e Epoch) IsZero() bool

IsZero returns true if zero.

func (Epoch) Time

func (e Epoch) Time() time.Time

Time converts epoch to a time.

type ErrCode

type ErrCode int

ErrCode is a specific internal error code.

const (
	ErrCodeMissingAuthToken      ErrCode = 104
	ErrCodeInvalidAuthToken      ErrCode = 105
	ErrCodeBadJSON               ErrCode = 106
	ErrCodeInvalidParameters     ErrCode = 107
	ErrCodeMissingParameters     ErrCode = 108
	ErrCodeInvalidPostedData     ErrCode = 109
	ErrCodeInvalidResourceID     ErrCode = 110
	ErrCodeMissingResource       ErrCode = 111
	ErrCodeMissingContentLength  ErrCode = 112
	ErrCodeRequestTooLarge       ErrCode = 113
	ErrCodeModifiedMeanwhile     ErrCode = 114
	ErrCodeMethodNotAllowed      ErrCode = 115
	ErrCodeVersionNotAvailable   ErrCode = 116
	ErrCodeClientReachedCapacity ErrCode = 117
	ErrCodeForbidden             ErrCode = 121
	ErrCodeConstraintViolated    ErrCode = 122
	ErrCodeBackend               ErrCode = 201
	ErrCodeServiceDeprecated     ErrCode = 202
	ErrCodeUndefined             ErrCode = 999
)

Error codes enum.

type Helpers

type Helpers struct {
	// contains filtered or unexported fields
}

Helpers provide access to elementary helper functions.

func CustomHelpers

func CustomHelpers(slowHash slowhash.Generator, nextID identity.Factory) *Helpers

CustomHelpers inits custom helpers.

func NewHelpers

func NewHelpers(opt HelpersOptions) (*Helpers, error)

NewHelpers inits helpers.

func (*Helpers) NextID

func (e *Helpers) NextID() string

NextID returns a new globally unique ID.

func (*Helpers) SlowHash

func (e *Helpers) SlowHash(plain string) (string, error)

SlowHash applies a password-hash to a plain string returning a cryptographically secure, hashed string.

type HelpersOptions

type HelpersOptions struct {
	Identity string // type of identity generator to use
	SlowHash string // type of slowhash to use
}

HelpersOptions are used to configure helpers.

type Path

type Path string

Path represents an object path.

func NormPath

func NormPath(path string) Path

NormPath parses a path from a URL path.

func (Path) Contains

func (p Path) Contains(other Path) bool

Contains returns true if path contains other.

func (Path) IsNode

func (p Path) IsNode() bool

IsNode returns true if the path addresses multiple resources.

func (Path) ObjectID

func (p Path) ObjectID() string

ObjectID extracts the object ID.

func (Path) Parent

func (p Path) Parent() Path

Parent returns the parent path.

func (Path) ResourceName

func (p Path) ResourceName() string

ResourceName extracts the resource name.

func (Path) Split

func (p Path) Split() (string, string)

Split splits the path into a namespace and object ID.

func (Path) String

func (p Path) String() string

String returns the path as a plain string.

func (Path) Traverse

func (p Path) Traverse(fn func(Path))

Traverse iterates over path and its parents.

func (Path) WithObjectID

func (p Path) WithObjectID(objectID string) Path

WithObjectID replaces the objectID of the path and returns the result.

Jump to

Keyboard shortcuts

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