web

package
v0.0.0-...-7690095 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2017 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReqmethodXMethodName = "X-HTTP-Method-Override"
	HTTPXForwardedFor    = "X-Forwarded-For"
	HTTPXRealIP          = "X-Real-IP"
	HTTPXRequestedWith   = "X-Requested-With"
)
View Source
const (
	UserAnonymous int = iota
	UserUser
	UserPremiumUser
	UserWriter
	UserSuperWriter
	UserModerator
	UserSuperModerator
	UserAdmin
	UserSuperAdmin
)

Variables

View Source
var ErrResourceNotFound = errors.New("resource not found")

Functions

func SetContentParser

func SetContentParser(ctype string, f ContentParser)

Types

type AppError

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

func (AppError) Code

func (ae AppError) Code() int

func (AppError) Error

func (ae AppError) Error() string

type CacheManager

type CacheManager interface {
	Get(string) interface{}
	MapValue(string, interface{})
	Set(string, interface{}, time.Duration)
	Delete(string)
	Clear()
}

type ContentParser

type ContentParser func(io.Reader) map[string]interface{}

func GetContentParser

func GetContentParser(ctype string) ContentParser

type Context

type Context struct {
	SetTitle_   func(string)
	Request     *http.Request
	Response    http.ResponseWriter
	UPath       UPath
	PData       PData
	Module      string
	Controller  string
	Action      string
	Ext         string
	Event       *event.Router
	Session     SessionManager
	Cache       CacheManager
	MaxFileSize int64
	WebSocket   *websocket.Conn
	// contains filtered or unexported fields
}

func NewContext

func NewContext(w http.ResponseWriter, r *http.Request) *Context

func NewSunnyContext

func NewSunnyContext(w http.ResponseWriter, r *http.Request, sunnyserver int) (ctxt *Context)

func (*Context) AddFlash

func (c *Context) AddFlash(msg string)

func (*Context) AddHeader

func (c *Context) AddHeader(header, value string)

func (*Context) AddHeaderVary

func (c *Context) AddHeaderVary(v string)

func (*Context) AllFlashes

func (c *Context) AllFlashes() []string

func (*Context) AppError

func (c *Context) AppError() (ae AppError)

func (*Context) ClientIP

func (c *Context) ClientIP(pref []string) (ip net.IP)

func (*Context) Close

func (c *Context) Close()

func (*Context) Cookie

func (c *Context) Cookie(cname string) (ck *http.Cookie)

func (*Context) CookieValue

func (c *Context) CookieValue(cname string) string

func (*Context) DeleteCookie

func (c *Context) DeleteCookie(cname string)

func (*Context) Error

func (c *Context) Error() string

func (*Context) ErrorCode

func (c *Context) ErrorCode() int

func (*Context) Flash

func (c *Context) Flash() string

func (*Context) FwdedForOrRmteAddr

func (c *Context) FwdedForOrRmteAddr() (ip net.IP)

func (*Context) HasError

func (c *Context) HasError() bool

func (*Context) HasErrorCode

func (c *Context) HasErrorCode() bool

func (*Context) HasFlash

func (c *Context) HasFlash() bool

func (*Context) IfNoneMatch

func (c *Context) IfNoneMatch(etag string) int

func (*Context) IsAJAX

func (c *Context) IsAJAX() bool

func (*Context) IsAJAXOrCORS

func (c *Context) IsAJAXOrCORS() bool

func (*Context) IsAjax

func (c *Context) IsAjax() bool

func (*Context) IsAjaxOrCors

func (c *Context) IsAjaxOrCors() bool

func (*Context) IsCORS

func (c *Context) IsCORS() bool

func (*Context) IsCors

func (c *Context) IsCors() bool

func (*Context) IsHTTPS

func (c *Context) IsHTTPS() bool

func (*Context) IsHttps

func (c *Context) IsHttps() bool

func (*Context) IsRedirecting

func (c *Context) IsRedirecting() bool

func (*Context) IsSunnyContext

func (c *Context) IsSunnyContext() bool

func (*Context) LenFlashes

func (c *Context) LenFlashes() int

func (*Context) MapResourceValue

func (c *Context) MapResourceValue(name string, ref interface{}) (err error)

func (*Context) Method

func (c *Context) Method() string

func (*Context) ParseRequestData

func (c *Context) ParseRequestData()

func (*Context) PeekFlashes

func (c *Context) PeekFlashes() []string

func (*Context) PostValue

func (c *Context) PostValue(name string) string

func (*Context) PostValues

func (c *Context) PostValues(name string) []string

func (*Context) PrivateNoCache

func (c *Context) PrivateNoCache()

func (*Context) PrivateNoStore

func (c *Context) PrivateNoStore()

func (*Context) PublicCache

func (c *Context) PublicCache(age int)

func (*Context) QueryStr

func (c *Context) QueryStr(s ...string) (qs Q)

func (*Context) RaiseAppError

func (c *Context) RaiseAppError(err string, status ...int)

func (*Context) RecoverError

func (c *Context) RecoverError()

func (*Context) Redirect

func (c *Context) Redirect(location string, state ...int)

func (*Context) RedirectOut

func (c *Context) RedirectOut(location string, state ...int)

func (*Context) Redirection

func (c *Context) Redirection() Redirection

func (*Context) RedirectionCode

func (c *Context) RedirectionCode() int

func (*Context) RedirectionURL

func (c *Context) RedirectionURL() string

func (*Context) RemoteAddress

func (c *Context) RemoteAddress() net.IP

func (*Context) ReqHeader

func (c *Context) ReqHeader(header string) string

func (*Context) ReqHeaderHas

func (c *Context) ReqHeaderHas(header, value string) bool

func (*Context) ReqHeaderIs

func (c *Context) ReqHeaderIs(header, value string) bool

func (*Context) RequestBodyData

func (c *Context) RequestBodyData(ctype string) map[string]interface{}

func (*Context) RequestValue

func (c *Context) RequestValue(name string) string

func (*Context) RequestValues

func (c *Context) RequestValues(name string) []string

func (*Context) ResHeader

func (c *Context) ResHeader(header string) string

func (*Context) Resource

func (c *Context) Resource(name string) (val interface{})

func (*Context) RootResponse

func (c *Context) RootResponse() (resp http.ResponseWriter)

func (*Context) SetCookie

func (c *Context) SetCookie(ck *http.Cookie)

func (*Context) SetCookieValue

func (c *Context) SetCookieValue(name, value string)

func (*Context) SetETag

func (c *Context) SetETag(etag string) string

func (*Context) SetError

func (c *Context) SetError(err string, status ...int)

func (*Context) SetErrorCode

func (c *Context) SetErrorCode(status int)

func (*Context) SetHeader

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

func (*Context) SetRedirect

func (c *Context) SetRedirect(location string, state ...int) int

func (*Context) SetRedirectOut

func (c *Context) SetRedirectOut(location string, state ...int) (status int)

func (*Context) SetResource

func (c *Context) SetResource(name string, ref interface{})

func (*Context) SetTitle

func (c *Context) SetTitle(title string)

func (*Context) StartTime

func (c *Context) StartTime() time.Time

func (*Context) SunnyServerID

func (c *Context) SunnyServerID() int

func (*Context) ToWebSocket

func (c *Context) ToWebSocket(upgrader *websocket.Upgrader, header http.Header) (err error)

func (*Context) URL

func (c *Context) URL(path string, qstr ...Q) string

func (*Context) URLQ

func (c *Context) URLQ(path string, s ...string) string

func (*Context) WaitRequestData

func (c *Context) WaitRequestData() error

func (*Context) XMethod

func (c *Context) XMethod() string

func (*Context) XRealIPOrRmteAddr

func (c *Context) XRealIPOrRmteAddr() (ip net.IP)

type ContextError

type ContextError interface {
	Error() string
	Code() int
}

type ContextHandler

type ContextHandler interface {
	ServeContextHTTP(*Context)
}

type ContextOptionsHandler

type ContextOptionsHandler interface {
	ServeContextOptions(*Context, map[string]string)
}

type ExpectationError

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

func (ExpectationError) Code

func (ee ExpectationError) Code() int

func (ExpectationError) Error

func (ee ExpectationError) Error() string

func (ExpectationError) IncomingSize

func (ee ExpectationError) IncomingSize() int64

func (ExpectationError) MaxFileSize

func (ee ExpectationError) MaxFileSize() int64

type FormDate

type FormDate time.Time

type FormDateTime

type FormDateTime time.Time

type FormEmail

type FormEmail string

type FormFloat

type FormFloat float32

type FormFloat64

type FormFloat64 float64

type FormInt

type FormInt int

type FormInt64

type FormInt64 int64

type FormString

type FormString string

type FormTime

type FormTime time.Duration

type FormURL

type FormURL string

type PData

type PData map[string]string

func (PData) Date

func (data PData) Date(key string) (d time.Time, err error)

func (PData) DateTime

func (data PData) DateTime(key string) (dt time.Time, err error)

func (PData) Email

func (data PData) Email(key string) (s string, err error)

func (PData) Float32

func (data PData) Float32(key string) (i float32, err error)

func (PData) Float64

func (data PData) Float64(key string) (i float64, err error)

func (PData) Int

func (data PData) Int(key string) (i int, err error)

func (PData) Int64

func (data PData) Int64(key string) (i int64, err error)

func (PData) String

func (data PData) String(key string) (s string, err error)

func (PData) Time

func (data PData) Time(key string) (t time.Duration, err error)

func (PData) URL

func (data PData) URL(key string) (s string, err error)

func (PData) Url

func (data PData) Url(key string) (string, error)

type PathFloat

type PathFloat float32

type PathFloat64

type PathFloat64 float64

type PathInt

type PathInt int

type PathInt64

type PathInt64 int64

type PathString

type PathString string

type Q

type Q map[string]string

type RedirectError

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

func (RedirectError) Code

func (re RedirectError) Code() int

func (RedirectError) Error

func (re RedirectError) Error() string

func (RedirectError) URL

func (re RedirectError) URL() string

type Redirection

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

func (Redirection) Code

func (r Redirection) Code() int

func (Redirection) URL

func (r Redirection) URL() string

type ResponseWriterChild

type ResponseWriterChild interface {
	ParentResponseWriter() http.ResponseWriter
}

type SessionManager

type SessionManager interface {
	ID() string
	String(string) string
	Int(string) int
	Int64(string) int64
	Float32(string) float32
	Float64(string) float64
	Bool(string) bool
	Byte(string) byte
	Get(string) interface{}
	MapValue(string, interface{})
	IPAddress() string
	UserAgent() string
	Created() time.Time
	Accessed() time.Time
	Expiry() time.Time
	AuthUser() UserModel
	Set(string, interface{})
	Remove(string)
	SetIPAddress(string)
	SetUserAgent(string)
	SetExpiry(time.Time)
	SetAuthUser(UserModel)
	SetAuthUserData(id, email, name string, lvl int)
	SetAnonymous()
	IsAuthUser(id string) bool
	UpdateAccessed()
	AddFlash(string)
	HasFlash() bool
	Flash() string
	AllFlashes() []string
	PeekFlashes() []string
	LenFlashes() int
}

type StatusCode

type StatusCode int

type UPath

type UPath []string

func (UPath) Float32

func (upath UPath) Float32(index int) (i float32, err error)

func (UPath) Float64

func (upath UPath) Float64(index int) (i float64, err error)

func (UPath) GetFloat32

func (upath UPath) GetFloat32(index int, def ...float32) (i float32)

func (UPath) GetFloat64

func (upath UPath) GetFloat64(index int, def ...float64) (i float64)

func (UPath) GetInt

func (upath UPath) GetInt(index int, def ...int) (i int)

func (UPath) GetInt64

func (upath UPath) GetInt64(index int, def ...int64) (i int64)

func (UPath) GetString

func (upath UPath) GetString(index int, def ...string) (s string)

func (UPath) Int

func (upath UPath) Int(index int) (i int, err error)

func (UPath) Int64

func (upath UPath) Int64(index int) (i int64, err error)

func (UPath) String

func (upath UPath) String(index int) (s string, err error)

type UserModel

type UserModel interface {
	ID() string
	Email() string
	Name() string
	Level() int
	IsSuperAdmin() bool
	IsAdmin() bool
	IsSuperModerator() bool
	IsModerator() bool
	IsSuperWriter() bool
	IsWriter() bool
	IsPremiumUser() bool
	IsUser() bool
	IsAnonymous() bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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