view

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const CERASALT = "Crea@2019=="

Variables

View Source
var (
	SessionExpired   = errors.New("session has been expired, logout")
	SessionNoThisKey = errors.New("has not key in session data")
)

Functions

func AESDecrypt

func AESDecrypt(src, key []byte) (dst []byte, err error)

decrypt by aes

func AESEncrypt

func AESEncrypt(src, key []byte) (dst []byte, err error)

encrypt by aes

func Capitalize

func Capitalize(str string) string

Capitalize: change first character to upper 改变字符串首字母为大写

func ConvertMapToStruct

func ConvertMapToStruct(params map[string]interface{}, val interface{})

ConvertMapToStruct params map fill struct

func CreateSessionId

func CreateSessionId(username string, userId interface{}) ([16]byte, error)

create new session, user id could not be repeat

func HtmlUnknownMethod

func HtmlUnknownMethod(ctx *fasthttp.RequestCtx)

func Sha1String

func Sha1String(key []byte, sum []byte) string

func Switcher

func Switcher(v IMethodViewer)

Types

type CreaCookie

type CreaCookie struct {
	ActionId [16]byte // action id of session,generate by timestamp and random uint
	XsrfKey  [8]byte  // xsrf key
	XsrfUid  [8]byte  // xsrf uid
}

func ParseCookie

func ParseCookie(ck []byte) *CreaCookie

parse cookie to struct

func (*CreaCookie) ToByte

func (c *CreaCookie) ToByte() []byte

generate struct to byte slice

type IMethodViewer

type IMethodViewer interface {
	Init()
	Before()
	Get()
	Post()
	Head()
	Options()
	Put()
	Patch()
	Delete()
	Trace()
	GetCtx() *fasthttp.RequestCtx
	SetCtx(ctx *fasthttp.RequestCtx)
	After()
	Render()
}

type IViewer

type IViewer interface {
	Before()
	After()
	GetCtx() *fasthttp.RequestCtx
	SetCtx(ctx *fasthttp.RequestCtx)
}

type JsonView added in v1.1.7

type JsonView struct {
	View
}

func (*JsonView) Render added in v1.1.7

func (r *JsonView) Render()

type Session

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

func NewSession

func NewSession(username string, userId interface{}, lifeCycle int64) (*Session, error)

func (*Session) Get

func (s *Session) Get(key string) (val interface{}, err error)

get session , Get() return value and error. if time expire, Get() will return timeout error

func (*Session) HasKey

func (s *Session) HasKey(key string) bool

check has key in session data or not

func (*Session) Set

func (s *Session) Set(key string, val interface{})

set session data

type View

type View struct {
	JinJaTpl bool
	Data     Data // stored user values
	Ctx      *fasthttp.RequestCtx
	Cookie   *fasthttp.Cookie
}

func (*View) After

func (r *View) After()

func (*View) Before

func (r *View) Before()

func (*View) Delete

func (r *View) Delete()

func (*View) Get

func (r *View) Get()

func (*View) GetArgBytes

func (r *View) GetArgBytes(key string) []byte

获取参数,通过标准get url方式传值 e.g. http://xxx.com/?id=1

func (*View) GetArgInt

func (r *View) GetArgInt(key string) (int, error)

获取参数,通过标准get url方式传值 e.g. http://xxx.com/?id=1

func (*View) GetArgString

func (r *View) GetArgString(key string) string

获取参数,通过标准get url方式传值 e.g. http://xxx.com/?id=1

func (*View) GetCtx

func (r *View) GetCtx() *fasthttp.RequestCtx

func (*View) GetPostArgs

func (r *View) GetPostArgs(key string) string

func (*View) Head

func (r *View) Head()

func (*View) Html404

func (r *View) Html404()

func (*View) Init

func (r *View) Init()

combine this struct and rewrite those functions to reply http methods

func (*View) Options

func (r *View) Options()

func (*View) Patch

func (r *View) Patch()

func (*View) Post

func (r *View) Post()

func (*View) Put

func (r *View) Put()

func (*View) Render

func (r *View) Render()

func (*View) SetCtx

func (r *View) SetCtx(ctx *fasthttp.RequestCtx)

func (*View) Trace

func (r *View) Trace()

type XmlView added in v1.1.8

type XmlView struct {
	View
}

func (*XmlView) Render added in v1.1.8

func (r *XmlView) Render()

Jump to

Keyboard shortcuts

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