manifold

package module
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

README

go-manifold

Go client API for manifold (unstable)

Code of Conduct | Contribution Guidelines

GitHub release GoDoc Travis Go Report Card License

Overview

This will be the Go implementation of a client API for Manifold's non-provider facing REST services. For now, it is unstable as we build it, and is used to share code between some of our other packages.

If you are a provider, you'll want to look at grafton for verifying your implementation, or go-signature for verifying requests have come from Manifold instead.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code added in v0.7.2

type Code string

Code represents a manifold verification code ( E-Mail Verification )

func (Code) Validate added in v0.7.2

func (c Code) Validate(_ interface{}) error

Validate ensures the name value is valid

type Email

type Email string

Email represents any email field

func (Email) Validate

func (e Email) Validate(_ interface{}) error

Validate ensures that the email is valid

type Error

type Error struct {
	Type     errors.Type `json:"type"`
	Messages []string    `json:"message"`
}

Error represents an Error returned by this Middleware to a requestor

func FromError

func FromError(err error) *Error

FromError returns an error of type Error from a struct that represents a

func NewError

func NewError(t errors.Type, m ...string) *Error

NewError returns an Error containing 1 or more error messages

func (*Error) Code

func (e *Error) Code() int32

Code returns the HTTP Status Code associated with this Error, completes the go-openapi error interface.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message represented by this Error

func (*Error) StatusCode

func (e *Error) StatusCode() int

StatusCode returns the HTTP Status Code associated with this error, completes the HTTPError interface.

func (*Error) WriteResponse

func (e *Error) WriteResponse(w http.ResponseWriter, pr runtime.Producer)

WriteResponse completes the interface for a middleware.Responder from go-openapi/runtime

A panic will occur if the given producer errors.

type HTTPError

type HTTPError interface {
	error
	StatusCode() int
	WriteResponse(http.ResponseWriter, runtime.Producer)
}

HTTPError interface represents an error that is returned to a user as an HTTP response

func ToError

func ToError(err error) HTTPError

ToError receives an error and mutates it into an Error based on the concrete type of the Error.

type ID

type ID [byteLength]byte

ID is an encoded unique identifier for an object.

The first byte holds the schema version of the id itself. The second byte holds the type of the object. The remaining 16 bytes hold a digest of the contents of the object for immutable objects, or a random value for mutable objects.

func DecodeIDFromString added in v0.0.2

func DecodeIDFromString(value string) (ID, error)

DecodeIDFromString returns an ID that is stored in the given string.

func DeriveMutableID added in v0.0.2

func DeriveMutableID(body Mutable, base ID, derivableType idtype.Type) ID

DeriveMutableID returns a ID for a mutable object based on another ID.

func NewFakeMutableID added in v0.0.2

func NewFakeMutableID(body Mutable, source string) (ID, error)

NewFakeMutableID returns an ID for a fake mutable object, not relying on the Body contents of the supplied mutable to generate the ID

func NewID

func NewID(t idtype.Type) (ID, error)

NewID returns a new ID for a Mutable idtype using only the Type

func NewImmutableID added in v0.0.2

func NewImmutableID(obj Immutable, sig interface{}) (ID, error)

NewImmutableID returns a new signed ID for an immutable object.

sig should be a registry.Signature type

func NewMutableID added in v0.0.2

func NewMutableID(body Mutable) (ID, error)

NewMutableID returns a new ID for a mutable object.

func (ID) IsEmpty added in v0.0.3

func (id ID) IsEmpty() bool

IsEmpty returns whether or not the ID is empty (all zeros)

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for IDs.

IDs are encoded in unpadded base32.

func (ID) String

func (id ID) String() string

func (ID) Type

func (id ID) Type() idtype.Type

Type returns the idtype.Type encoded object type represented by this ID.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for IDs.

func (ID) Validate

func (id ID) Validate(_ interface{}) error

Validate implements the Validate interface for goswagger. We know that if the value has successfully parsed, it is valid, so no action is required.

type Identifiable

type Identifiable interface {
	GetID() ID
	Version() int
	Type() idtype.Type
}

Identifiable is the interface implemented by objects that can be given IDs.

type Immutable

type Immutable interface {
	Identifiable
	GetBody() interface{}
	Immutable() // We don't ever need to call this, its just for type checking.
}

Immutable structs are Identifiables that do not change, and should be signed.

type Label

type Label string

Label represents any object's label field

func (Label) Validate

func (lbl Label) Validate(_ interface{}) error

Validate ensures the label value is valid

type Mutable

type Mutable interface {
	Identifiable
	Mutable() // also just for type checking.
}

Mutable structs are Identifiables that can be changed.

type Name

type Name string

Name represents any object's name field

func (Name) Validate

func (n Name) Validate(_ interface{}) error

Validate ensures the name value is valid

Directories

Path Synopsis
Package idtype contains our enumeration of all registered types.
Package idtype contains our enumeration of all registered types.

Jump to

Keyboard shortcuts

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