webutil

package module
v0.0.0-...-8a6a78f Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2018 License: MIT Imports: 19 Imported by: 3

README

"# webutil"

Documentation

Index

Constants

View Source
const (
	ErrorKey _errorKey = iota
	ErrorInfo
)
View Source
const (
	BufPoolkey _bufpooltype = iota
)
View Source
const (
	PageTypeCache _pageTypeCacheKey = iota
)
View Source
const (
	PersistentCookieKey _persistentCookieKey = iota
)
View Source
const (
	RendererKey _rendererKey = iota
)
View Source
const SessionName _sessionName = 0
View Source
const TPLFieldConfig = "TPLConfig"
View Source
const TPLName = "webtpl"
View Source
const TPLRootKey _templateType = 0

Variables

View Source
var BufPoolSize = 16
View Source
var DefaultMidSeq func(fn interface{}, params []interface{}) http.Handler
View Source
var ErrNoRootTPL = fmt.Errorf("no root template found.")

Functions

func AddDebugLoggerHandler

func AddDebugLoggerHandler(fnDebug logfn.LogFunc) http.Handler

func AddError

func AddError(ctx context.Context, err error)

func AddFilesToRootTPL

func AddFilesToRootTPL(filenames ...string) http.HandlerFunc

func AddGlobToRootTPL

func AddGlobToRootTPL(pattern string) http.HandlerFunc

func AddLoggerHandler

func AddLoggerHandler(fnInfo, fnErr, fnWarn logfn.LogFunc) http.Handler

func CreatePersistentCookie

func CreatePersistentCookie(fnGetCookie func(context.Context) (*cookiejar.Jar, error)) http.HandlerFunc

func CurrentSession

func CurrentSession(ctx context.Context) (o *sessions.Session, exists bool)

func EnsureHTTPS

func EnsureHTTPS(w http.ResponseWriter, r *http.Request)

func ErrLoggerHandler

func ErrLoggerHandler(fn logfn.LogFunc) http.Handler

func GenRandSecrets

func GenRandSecrets(count int) [][]byte

func GetCookie

func GetCookie(ctx context.Context) *cookiejar.Jar

func GetErrorInfo

func GetErrorInfo(ctx context.Context) interface{}

func GetPageDataKVConfig

func GetPageDataKVConfig(c Store, page interface{}) (m map[string]string)

example of page[0] struct

type SomePage struct {
		TPLConfig string `webtpl:"name=mytemplate.tpl"`
	}

func GetPageTypeCache

func GetPageTypeCache(c Store) (m map[string]map[string]string)

func GetRenderer

func GetRenderer(ctx context.Context) *_Renderer

func GetRootTPL

func GetRootTPL(ctx context.Context) *template.Template

func GetSession

func GetSession(ctx context.Context) *sessions.Session

func HttpSequence

func HttpSequence(finally http.HandlerFunc, h ...http.HandlerFunc) http.HandlerFunc

func IfHasErrorRedirect

func IfHasErrorRedirect(theURL string, moreinfo interface{}) http.HandlerFunc

func IfSuccessRedirect

func IfSuccessRedirect(theURL string) http.HandlerFunc

func InfoLoggerHandler

func InfoLoggerHandler(fn logfn.LogFunc) http.Handler

func LogDebug

func LogDebug(ctx context.Context, fmt string, params ...interface{})

func LogErr

func LogErr(ctx context.Context, fmt string, params ...interface{})

func LogInfo

func LogInfo(ctx context.Context, fmt string, params ...interface{})

func LogWarn

func LogWarn(ctx context.Context, fmt string, params ...interface{})

func MarshalKeys

func MarshalKeys(keys [][]byte) ([]byte, error)

func MergeMapStrIf

func MergeMapStrIf(dst, src map[string]interface{})

func MergePageData

func MergePageData(c Store, data map[string]interface{}, page interface{})

func MergePageFuncs

func MergePageFuncs(c Store, funcs map[string]interface{}, page interface{})

func MergePagesData

func MergePagesData(c Store, datamap map[string]interface{}, pages ...interface{})

func MergePagesFuncs

func MergePagesFuncs(c Store, funcmap map[string]interface{}, pages ...interface{})

func Method

func Method(method string, nexth http.Handler) http.Handler

func MidSeq

func MidSeq(handlerToWrap http.Handler, fs ...*MidInfo) http.Handler

func MidSeqFunc

func MidSeqFunc(handlerToWrap http.HandlerFunc, fs ...*MidInfo) http.Handler

func NewRenderer

func NewRenderer(c context.Context, t *template.Template) *_Renderer

func NoCache

func NoCache(h http.Handler) http.Handler

func OnErrorGotoReferrer

func OnErrorGotoReferrer(h http.HandlerFunc, moreinfo interface{}) http.HandlerFunc

func OnErrorRedirect

func OnErrorRedirect(h http.HandlerFunc, theURL string, moreinfo interface{}) http.HandlerFunc

func RedirectHandler

func RedirectHandler(urlstr string, code int) http.Handler

func SavePersistentCookie

func SavePersistentCookie(fnSaveCookie func(c context.Context, jar http.CookieJar) error) http.HandlerFunc

func SetRootTemplate

func SetRootTemplate(ctx context.Context, tpl *template.Template) http.HandlerFunc

func UnmarshalKeys

func UnmarshalKeys(bb []byte) (keys [][]byte, err error)

func UseDbiCache

func UseDbiCache(namespace string, dbiKey interface{}) http.HandlerFunc

func UseRenderer

func UseRenderer(glob string, filenames ...string) http.HandlerFunc

func WithDebugLogger

func WithDebugLogger(ctx context.Context, fn logfn.LogFunc) context.Context

func WithErrLogger

func WithErrLogger(ctx context.Context, fn logfn.LogFunc) context.Context

func WithInfoLogger

func WithInfoLogger(ctx context.Context, fn logfn.LogFunc) context.Context

func WithWarnLogger

func WithWarnLogger(ctx context.Context, fn logfn.LogFunc) context.Context

Types

type BufPool

type BufPool interface {
	Get() *bytes.Buffer
	Put(buf *bytes.Buffer)
}

func GetBufPool

func GetBufPool(ctx context.Context) BufPool

type DbiCache

type DbiCache struct {
	gae.DbExInt
	// contains filtered or unexported fields
}

func GetDbiCache

func GetDbiCache(namespace string, oDbi gae.DbExInt) *DbiCache

func (*DbiCache) Get

func (this *DbiCache) Get(k string) (bb []byte, err error)

func (*DbiCache) GetObject

func (this *DbiCache) GetObject(k string, o interface{}) (err error)

func (*DbiCache) Put

func (this *DbiCache) Put(k string, bb []byte) error

func (*DbiCache) PutObject

func (this *DbiCache) PutObject(k string, o interface{}) error

type HasHTML

type HasHTML interface {
	GetHTMLContent() string
}

type MidInfo

type MidInfo struct {
	Fn     interface{}
	Params []interface{}
}

func MidFn

func MidFn(fn interface{}, params ...string) *MidInfo

func MidFnIf

func MidFnIf(fn interface{}, params ...interface{}) *MidInfo

func MidLogFn

func MidLogFn(fn interface{}, a logfn.LogFunc) *MidInfo

type SessionStore

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

func NewCookieSession

func NewCookieSession(opts *sessions.Options, keys ...[]byte) *SessionStore

func NewFilesystemSession

func NewFilesystemSession(fpath string, opts *sessions.Options, keys ...[]byte) *SessionStore

func (*SessionStore) AddSessionHandler

func (this *SessionStore) AddSessionHandler(name string) http.HandlerFunc

func (*SessionStore) Domain

func (this *SessionStore) Domain(s string)

func (*SessionStore) HttpOnly

func (this *SessionStore) HttpOnly(b bool)

func (*SessionStore) MaxAge

func (this *SessionStore) MaxAge(n int)

func (*SessionStore) Path

func (this *SessionStore) Path(s string)

func (*SessionStore) Secure

func (this *SessionStore) Secure(b bool)

type Store

type Store interface {
	Set(k, v interface{})
	Get(k interface{}) (interface{}, bool)
}

func ToStore

func ToStore(c context.Context) Store

Jump to

Keyboard shortcuts

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