handlers

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: MPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpOnlyCookieName  = "wt-http-token-cookie"
	JsVisibleCookieName = "wt-js-token-cookie"
)

Variables

This section is empty.

Functions

func ApiErrorWithCode

func ApiErrorWithCode(c codes.Code) error

ApiErrorWithCode returns an api error with the provided code.

func ApiErrorWithCodeAndMessage

func ApiErrorWithCodeAndMessage(c codes.Code, msg string, args ...interface{}) error

ApiErrorWithCodeAndMessage returns an api error with the provided code and message.

func ErrorHandler

func ErrorHandler(logger hclog.Logger) runtime.ErrorHandlerFunc

func ForbiddenError

func ForbiddenError() error

func GetOpts added in v0.2.0

func GetOpts(opt ...Option) options

GetOpts - iterate the inbound Options and return a struct

func InvalidArgumentErrorf

func InvalidArgumentErrorf(msg string, fields map[string]string) *apiError

func JSONMarshaler added in v0.2.1

func JSONMarshaler() *runtime.JSONPb

JSONMarshaler provides marshaler used for marshalling all proto as JSON in a format expected by the user facing controller API.

func MaskContains

func MaskContains(paths []string, s string) bool

func NotFoundError

func NotFoundError() error

NotFoundError returns an ApiError indicating a resource couldn't be found.

func NotFoundErrorf

func NotFoundErrorf(msg string, a ...interface{}) *apiError

NotFoundErrorf returns an ApiError indicating a resource couldn't be found.

func OutgoingInterceptor

func OutgoingInterceptor(ctx context.Context, w http.ResponseWriter, m proto.Message) error

func ProtoToStruct

func ProtoToStruct(p proto.Message) (*structpb.Struct, error)

func StructToProto

func StructToProto(fields *structpb.Struct, p proto.Message, opt ...Option) error

func ToApiError added in v0.2.1

func ToApiError(e error) *pb.Error

func UnauthenticatedError

func UnauthenticatedError() error

func ValidId

func ValidId(i Id, prefixes ...string) bool

func ValidNameDescription added in v0.1.1

func ValidNameDescription(in string) bool

func ValidateCreateRequest

func ValidateCreateRequest(i ApiResource, fn CustomValidatorFunc) error

func ValidateDeleteRequest

func ValidateDeleteRequest(fn CustomValidatorFunc, r DeleteRequest, prefix ...string) error

func ValidateGetRequest

func ValidateGetRequest(fn CustomValidatorFunc, r GetRequest, prefix ...string) error

func ValidateUpdateRequest

func ValidateUpdateRequest(r UpdateRequest, i ApiResource, fn CustomValidatorFunc, prefix ...string) error

Types

type ApiResource

type ApiResource interface {
	GetId() string
	GetScope() *scopes.ScopeInfo
	GetName() *wrappers.StringValue
	GetDescription() *wrappers.StringValue
	GetCreatedTime() *timestamp.Timestamp
	GetUpdatedTime() *timestamp.Timestamp
	GetVersion() uint32
}

type CustomValidatorFunc

type CustomValidatorFunc func() map[string]string
var NoopValidatorFn CustomValidatorFunc = func() map[string]string { return nil }

type DeleteRequest

type DeleteRequest interface {
	GetId() string
}

type Filter added in v0.1.8

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

func NewFilter added in v0.1.8

func NewFilter(f string) (*Filter, error)

NewFilter returns a Filter which can be evluated against. An empty string paramter indicates all items passed to it should succeed.

func (*Filter) Match added in v0.1.8

func (f *Filter) Match(item interface{}) bool

Match returns if the provided interface matches the filter. If the filter does not match the structure of the object being Matched, false is returned. TODO: Support more than just matching against the item being filtered. Also allow matching against

values in the request or the request context itself.

type GetRequest

type GetRequest interface {
	GetId() string
}

type Id added in v0.2.0

type Id string

A boundary resource identifier

type MaskManager

type MaskManager map[string]string

func NewMaskManager

func NewMaskManager(dest protoreflect.ProtoMessage, src ...protoreflect.ProtoMessage) (MaskManager, error)

NewMaskManager returns a mask manager that can translate field masks into the first proto from all subsequent protos assuming they are both using the mask_mapping custom option. Error is returned if no mappings are found or if one of the passed protos has a mapping that doesn't reciprocate.

func (MaskManager) Translate

func (m MaskManager) Translate(paths []string) []string

Translate takes a field mask's paths and returns paths translated for the destination's protobuf.

type Option added in v0.2.0

type Option func(*options)

Option - how Options are passed as arguments. Some of these are used for types within the handlers package, and some are for handlers to re-use across the various handler types.

func WithAuthorizedActions added in v0.2.1

func WithAuthorizedActions(acts []string) Option

WithAuthorizedActions provides an option when creating responses to include the given authorized actions if allowed

func WithAuthorizedCollectionActions added in v0.2.1

func WithAuthorizedCollectionActions(colActs map[string]*structpb.ListValue) Option

WithAuthorizedCollectionActions provides an option when creating responses to include the given authorized collection actions if allowed

func WithDiscardUnknownFields added in v0.2.0

func WithDiscardUnknownFields(discard bool) Option

WithDiscardUnknownFields provides an option to cause StructToProto to ignore unknown fields. This is useful in some instances when we need to unmarshal a value from a pb.Struct after we've added some custom extra fields.

func WithLogger added in v0.2.0

func WithLogger(logger hclog.Logger) Option

WithLogger provides an option include a logger

func WithOutputFields added in v0.2.1

func WithOutputFields(fields *perms.OutputFieldsMap) Option

WithOutputFields provides an option when creating responses to only include specific fields

func WithScope added in v0.2.1

func WithScope(scp *scopes.ScopeInfo) Option

WithScope provides an option when creating responses to include the given scope if allowed

func WithUserIsAnonymous added in v0.2.1

func WithUserIsAnonymous(anonListing bool) Option

DEPRECATED: Superceded by WithOutputFields. Will be removed once all handlers have been migrated to that.

type UpdateRequest

type UpdateRequest interface {
	GetId() string
	GetUpdateMask() *field_mask.FieldMask
}

Jump to

Keyboard shortcuts

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