comm

package
v0.0.0-...-d5996f0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package implements functions to decode values of a html form.

Index

Constants

This section is empty.

Variables

View Source
var PwdKey = []byte(conf.AESKey)

16 24 32位字符串 分别对应AES-128 AES-192 AES-256 加密方法 key不能泄露

Functions

func AesEncryptBase64Encode

func AesEncryptBase64Encode(data []byte) (string, error)

AES加密得到切片,不方便写入客户端cookie,密文做base64编码

func Base64DecodeAesDecrypt

func Base64DecodeAesDecrypt(base64string string) ([]byte, error)

func Decode

func Decode(vs url.Values, dst interface{}) error

Decode decodes the url.Values into a element that must be a pointer to a type provided by argument

func SetGlobalCookie

func SetGlobalCookie(ctx iris.Context, name string, value string)

设置全局 cookie

func TypeConversion

func TypeConversion(value string, ntype string) (reflect.Value, error)

类型转换

Types

type Consistent

type Consistent struct {

	// map 读写锁
	sync.RWMutex
	// contains filtered or unexported fields
}

保存一致性hash信息

func NewConsistent

func NewConsistent() *Consistent

一致性哈希实例构造函数 设置默认节点数量

func (*Consistent) Add

func (c *Consistent) Add(element string)

向hash环中添加1个节点

func (*Consistent) Get

func (c *Consistent) Get(element string) (string, error)

根据数据标示获取最近的服务器节点信息

func (*Consistent) Remove

func (c *Consistent) Remove(element string)

向hash环中删除1个节点

type DecodeCustomType

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

DecodeCustomType fields for custom types

type DecodeCustomTypeField

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

DecodeCustomTypeField is a function registered for a specific field of the struct passed to the Decoder

type DecodeCustomTypeFunc

type DecodeCustomTypeFunc func([]string) (interface{}, error)

DecodeCustomTypeFunc is a function that indicate how should to decode a custom type

type Decoder

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

Decoder the main to decode the values

func NewDecoder

func NewDecoder(opts *DecoderOptions) *Decoder

NewDecoder creates a new instance of Decoder

func (Decoder) Decode

func (dec Decoder) Decode(vs url.Values, dst interface{}) error

Decode decodes the url.Values into a element that must be a pointer to a type provided by argument

func (*Decoder) RegisterCustomType

func (dec *Decoder) RegisterCustomType(fn DecodeCustomTypeFunc, types []interface{}, fields []interface{}) *Decoder

RegisterCustomType It is the method responsible for register functions for decoding custom types

type DecoderOptions

type DecoderOptions struct {
	// TagName indicates the tag name for decoding a value by the tag
	TagName string
	// PrefUnmarshalText indicates if should to give preference to UnmarshalText over custom type registered
	PrefUnmarshalText bool
	// IgnoreUnknownKeys controls the behaviour when the decoder encounters unknown keys in the map. If i is true and an unknown field is encountered, it is ignored. This is similar to how unknown keys are handled by encoding/json. If i is false then Decode will return an error. Note that any valid keys will still be decoded in to the target struct.
	IgnoreUnknownKeys bool
}

DecoderOptions options for decoding the values

type Error

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

func (*Error) Cause

func (s *Error) Cause() error

Cause implements the causer interface from github.com/pkg/errors.

func (*Error) Error

func (s *Error) Error() string

func (Error) MarshalJSON

func (s Error) MarshalJSON() ([]byte, error)

type Filter

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

秒杀用户请求拦截器

func NewFilter

func NewFilter() *Filter

Filter构造函数

func (*Filter) GetFilterHandle

func (f *Filter) GetFilterHandle(uri string) FilterHandle

根据Uri获取对应 handle

func (*Filter) Handle

func (f *Filter) Handle(webHandle WebHandle) func(w http.ResponseWriter, r *http.Request)

执行拦截器,返回函数类型

func (*Filter) RegisterFilterUri

func (f *Filter) RegisterFilterUri(uri string, handler FilterHandle)

注册拦截器

type FilterHandle

type FilterHandle func(w http.ResponseWriter, r *http.Request) error

声明1个新的数据类型 函数类型 Go可以把函数当作类型

type WebHandle

type WebHandle func(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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