webo

package module
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatcherMiddleware

func CatcherMiddleware(debugFlag int, name string, url_log string, version string, poste string) func(next http.Handler) http.Handler

func DirectCatcherMiddleware added in v0.18.0

func DirectCatcherMiddleware(debugFlag int, name string, url_log string, version string, poste string) func(next http.Handler) http.Handler

NOT TESTED DirectCatcherMiddleware sans httptest.NewRecord, envoi direct vers http.ResponseWriter possible http: superfluous response.WriteHeader à ignorer

func FmtOptions

func FmtOptions(slice interface{}, sel interface{}) template.HTML

func FmtOptionsGroup

func FmtOptionsGroup(slice interface{}, sel interface{}) template.HTML

func HandleStaticFS added in v0.19.0

func HandleStaticFS(path string, fs fs.FS, maxAge int) func(w http.ResponseWriter, r *http.Request)

with embed mux.HandleFunc("/static/", webo.HandleStaticFs("/static/", static.StaticFS, 3600*24)) with disk mux.HandleFunc("/static/", webo.HandleStaticFs("/static/", os.DirFS("static"), 3600*24)) with gorilla r.PathPrefix("/static/").HandlerFunc(HandleStaticFS("/static/", static.StaticFiles, 3600*24))

func HandleStaticFSOrigin added in v0.19.0

func HandleStaticFSOrigin(path string, fs fs.FS, maxAge int, origin string) func(w http.ResponseWriter, r *http.Request)

func Log

func Log(r *http.Request)

func LogMiddleware

func LogMiddleware(next http.Handler) http.Handler

HTTP middleware setting a value on the request context

func RequestCatcherLog

func RequestCatcherLog(r *http.Request) *log.Logger

renvoi le log lui-même créé par catcher et positionné dans context

func RequestTx

func RequestTx(r *http.Request) *sqlx.Tx

func SessionMiddleware

func SessionMiddleware(auth string, key string, age int) func(next http.Handler) http.Handler

deprecate : use SessionNameMiddleware

func SessionNameMiddleware

func SessionNameMiddleware(name string, auth string, key string, age int) func(next http.Handler) http.Handler

session with possibility to set the name

func StaticDiskMiddleware

func StaticDiskMiddleware(path string, maxAge int) func(next http.Handler) http.Handler

with gorilla mux.Router (gorilla must know that /static exists) add a static middleware from disk with : Cache-Control max-age=maxAge

func StaticDiskMiddlewareOrigin

func StaticDiskMiddlewareOrigin(path string, maxAge int, origin string) func(next http.Handler) http.Handler

with gorilla mux.Router (gorilla must know that /static exists) add a static middleware from disk with : Cache-Control max-age=maxAge Access-Control-Allow-Origin origin

func StaticFsMiddleware

func StaticFsMiddleware(path string, fs fs.FS, maxAge int) func(next http.Handler) http.Handler

with gorilla mux.Router (gorilla must know that /static exists) add a static middleware from fs.FS with : Cache-Control maxAge

func StaticFsMiddlewareOrigin

func StaticFsMiddlewareOrigin(path string, fs fs.FS, maxAge int, origin string) func(next http.Handler) http.Handler

with gorilla mux.Router (gorilla must know that /static exists) add a static middleware from fs.FS with : Cache-Control max-age=maxAge Access-Control-Allow-Origin origin

func TxMiddleware

func TxMiddleware(db *sqlx.DB) func(next http.Handler) http.Handler

Types

type Catcher

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

func NewCatcher

func NewCatcher(debug int, name string, url_log string, version string, poste string, h http.Handler) *Catcher

func (*Catcher) ServeHTTP

func (h *Catcher) ServeHTTP(wrt http.ResponseWriter, r *http.Request)

type DayWriter

type DayWriter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func GetDayWriter

func GetDayWriter() *DayWriter

func (*DayWriter) Close

func (w *DayWriter) Close() error

func (*DayWriter) Write

func (w *DayWriter) Write(output []byte) (int, error)

création du fichier si inexistant ou si celui existant est plus vieux de 24h

type ErrRedirect

type ErrRedirect struct {
	URL string
}

func Redirect

func Redirect(url string, args ...any) ErrRedirect

func (ErrRedirect) Error

func (e ErrRedirect) Error() string

type JustFiles

type JustFiles struct {
	FS http.FileSystem
}

http.FileSystem without showing index of directories just serve explicit files

func (JustFiles) Open

func (fs JustFiles) Open(name string) (http.File, error)

type LogSender

type LogSender struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLogSender

func NewLogSender(name, poste, version, url_log string) *LogSender

func (*LogSender) Write

func (w *LogSender) Write(output []byte) (int, error)

type OptionAttrer

type OptionAttrer interface {
	OptionAttrs() template.HTMLAttr
}

type OptionGroupInt

type OptionGroupInt struct {
	OptionGroup string
	OptionValue int
	OptionLabel string
}

type OptionGroupString

type OptionGroupString struct {
	OptionGroup string
	OptionValue string
	OptionLabel string
}

type OptionInt

type OptionInt struct {
	OptionValue int
	OptionLabel string
}

type OptionString

type OptionString struct {
	OptionValue string
	OptionLabel string
}

type Session

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

func NewSession

func NewSession(auth string, key string, age int, next http.Handler) *Session

func (*Session) ServeHTTP

func (s *Session) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SessionStore

type SessionStore struct {
	*sessions.Session
}

func RequestSession

func RequestSession(r *http.Request) *SessionStore

func (*SessionStore) AddFlash

func (f *SessionStore) AddFlash(flag string, msg string)

func (*SessionStore) AddFlashf

func (f *SessionStore) AddFlashf(flag string, msg string, a ...interface{})

func (*SessionStore) Alert

func (f *SessionStore) Alert(msg string)

func (*SessionStore) Alertf

func (f *SessionStore) Alertf(msg string, a ...interface{})

func (*SessionStore) Alerts

func (f *SessionStore) Alerts() []string

func (*SessionStore) Flashes

func (f *SessionStore) Flashes(flag string) []string

func (*SessionStore) GetDate

func (f *SessionStore) GetDate(key string) (time.Time, error)

func (*SessionStore) GetForm

func (f *SessionStore) GetForm(key string) (url.Values, error)

func (*SessionStore) GetInt

func (f *SessionStore) GetInt(key string) (int, error)

func (*SessionStore) GetString

func (f *SessionStore) GetString(key string) string

func (*SessionStore) Info

func (f *SessionStore) Info(msg string)

func (*SessionStore) Infof

func (f *SessionStore) Infof(msg string, a ...interface{})

func (*SessionStore) Infos

func (f *SessionStore) Infos() []string

func (*SessionStore) PutDate

func (f *SessionStore) PutDate(key string, value time.Time)

func (*SessionStore) PutForm

func (f *SessionStore) PutForm(key string, u url.Values)

func (*SessionStore) PutInt

func (f *SessionStore) PutInt(key string, value int)

func (*SessionStore) PutString

func (f *SessionStore) PutString(key string, value string)

func (*SessionStore) Warning

func (f *SessionStore) Warning(msg string)

func (*SessionStore) Warningf

func (f *SessionStore) Warningf(msg string, a ...interface{})

func (*SessionStore) Warnings

func (f *SessionStore) Warnings() []string

type TX

type TX struct {
	DB *sqlx.DB
	// contains filtered or unexported fields
}

func NewTx

func NewTx(db *sqlx.DB, h http.Handler) *TX

func (*TX) ServeHTTP

func (t *TX) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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