server

package
v0.0.0-...-9b0dd16 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package server はサーバーアプリの実装です。

Index

Constants

View Source
const (
	// ProtectingCopyDefaultStructTag is the default tag name to test fields not to copy
	ProtectingCopyDefaultStructTag = "protectfor"
)

Variables

View Source
var (
	// IsNonStruct decides to treat the value is non-struct,
	// like time.Time and so on.
	IsNonStruct = func(v interface{}) bool {
		switch v.(type) {
		case time.Time:
			return true
		}
		return false
	}
)

Functions

func ProtectingBind

func ProtectingBind(binder func(dst interface{}) error, dst interface{}, protectFor string) error

ProtectingBind wraps binging functions such as echo.Context.Bind(), providing field protection.

func ProtectingCopy

func ProtectingCopy(dst, src interface{}, protectFor string) error

ProtectingCopy performs deepcopy excluding fields with the tag whose key is "protectfor" and value is specified with `protectFor`. dst and src must suffice one of followings: * src and dst are non-nil pointers of the same type. * src and dst are the non-nil map. * src and dst are the non-nil slice with the same length.

Types

type Entity

type Entity struct {
	ID            int64     `json:"id" datastore:"-" goon:"id" protectfor:"update"`
	Name          string    `json:"name" datastore:",noindex"`
	ScheduledDate time.Time `json:"scheduledDate" datastore:",noindex"`
	CreatedAt     time.Time `json:"createdAt" protectfor:"update"`
}

Entity は適当なモデルです。

type ErrCopyTypeMismatch

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

ErrCopyTypeMismatch represents an error caused for type mismatching between source and destination.

func NewErrCopyTypeMismatch

func NewErrCopyTypeMismatch(dType, sType reflect.Type) *ErrCopyTypeMismatch

NewErrCopyTypeMismatch creates a new ErrCopyTypeMismatch.

func (*ErrCopyTypeMismatch) Error

func (e *ErrCopyTypeMismatch) Error() string

type ErrCopyValueInvalid

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

ErrCopyValueInvalid represents a failure of copy caused for the source or the destination is invalid (e.g. is nil)

func (*ErrCopyValueInvalid) Error

func (e *ErrCopyValueInvalid) Error() string

type ProtectingCopier

type ProtectingCopier struct {
	// StructTag is the tag name to test fields not to copy.
	// If not specified, ProtectingCopyDefaultStructTag is used.
	StructTag string
	// ProtectFor is the tag value to test fields not to copy
	ProtectFor string
}

ProtectingCopier is the configuration to perform protecting copy

func (*ProtectingCopier) Copy

func (c *ProtectingCopier) Copy(dst, src interface{}) error

Copy performs deepcopy protecting fields specified with tag. dst and src must suffice one of followings: * src and dst are non-nil pointers of the same type. * src and dst are the non-nil map. * src and dst are the non-nil slice with the same length.

Jump to

Keyboard shortcuts

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