web

package
v0.0.0-...-ef29808 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Router = router{
	// contains filtered or unexported fields
}

Functions

func NewCache

func NewCache(maxBytes int64) *cache

func RandomString

func RandomString(n int) string

func Register

func Register(f ICtrl, prefix string)

func SetCookieConfig

func SetCookieConfig(c *CookieConfig)

func SetSessionConfig

func SetSessionConfig(s *SessionConfig)

func SizeStruct

func SizeStruct(data interface{}) int64

func Start

func Start(addr string)

Types

type BaseCtrl

type BaseCtrl struct {
}

func (*BaseCtrl) Del

func (u *BaseCtrl) Del(c *Context)

func (*BaseCtrl) Get

func (u *BaseCtrl) Get(c *Context)

func (*BaseCtrl) Post

func (u *BaseCtrl) Post(c *Context)

func (*BaseCtrl) Put

func (u *BaseCtrl) Put(c *Context)

type Context

type Context struct {
	Res     http.ResponseWriter
	Req     *http.Request
	Session ISession
	// 请求为Get类型时,Path去掉路由前缀的部分,不含?及其之后的内容
	PathG string
	// contains filtered or unexported fields
}

func (*Context) HTML

func (c *Context) HTML(html string)

func (*Context) JSON

func (c *Context) JSON(obj interface{})

func (*Context) Next

func (c *Context) Next()

func (*Context) PostForm

func (c *Context) PostForm(key string) string

func (*Context) Query

func (c *Context) Query(key string) string

func (*Context) SetHeader

func (c *Context) SetHeader(key string, value string)

type CookieConfig

type CookieConfig struct {
	SessionCookieName string
	Cache             ICache
	Path              string // optional
	Domain            string // optional
	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
	// MaxAge>0 means Max-Age attribute present and given in seconds
	MaxAge   int
	Secure   bool
	HttpOnly bool
}

type DefHandler

type DefHandler struct {
}

func (*DefHandler) ServeHTTP

func (handler *DefHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type EleMapValue

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

type ICache

type ICache interface {
	Get(key string) interface{}
	Set(key string, data interface{})
}

type ICtrl

type ICtrl interface {
	Get(c *Context)
	Post(c *Context)
	Del(c *Context)
	Put(c *Context)
}

ctrl func: Get Post Del Put

type ISession

type ISession interface {
	Get(key string) interface{}
	Set(key string, data interface{})
	SetCache(cache ICache)
	LastTime() time.Time
	SetLastTime(t time.Time)
	SessionID() string
}

type Session

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

func NewSession

func NewSession(cache ICache) *Session

func (*Session) Get

func (s *Session) Get(key string) interface{}

func (*Session) LastTime

func (s *Session) LastTime() time.Time

func (*Session) SessionID

func (s *Session) SessionID() string

func (*Session) Set

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

func (*Session) SetCache

func (s *Session) SetCache(cache ICache)

func (*Session) SetLastTime

func (s *Session) SetLastTime(t time.Time)

type SessionConfig

type SessionConfig struct {
	MaxAge time.Duration
}

Jump to

Keyboard shortcuts

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