Documentation ¶
Index ¶
- Constants
- func EncodeRandomKey() string
- func NewRouter() *mux.Router
- func RDebug(r *http.Request)
- func RId(r *http.Request) string
- func RLog(r *http.Request) *slog.Logger
- func RSet(r *http.Request, key string, value any)
- func RedirectTo(w http.ResponseWriter, r *http.Request, routeName string, pathVars ...string)
- func RedirectToUrl(w http.ResponseWriter, r *http.Request, url string)
- func Render(w http.ResponseWriter, r *http.Request, templateFile string, ...)
- func RenderError(w http.ResponseWriter, r *http.Request, err error, msg string, statusCode int)
- func WithMiddleware(h http.Handler, withTLS bool) http.Handler
- type CsrfProtection
- type RenderOpt
- type Session
- type SessionStore
Constants ¶
View Source
const ( CsrfFormToken = "_csrf_token" CsrfHttpHeader = "X-Csrf-Token" CsrfTokenKey = "CsrfToken" )
View Source
const ( FlashMessageKey = "FlashMessage" FlashSuccessKey = "FlashSuccess" FlashWarningKey = "FlashWarning" FlashErrorKey = "FlashError" )
Variables ¶
This section is empty.
Functions ¶
func EncodeRandomKey ¶
func EncodeRandomKey() string
func RDebug ¶
RDebug sets this request to be logged at DEBUG level rather than the INFO default. Useful, for example, for health check endpoints so that they don't flood production logs.
func RedirectTo ¶
func RedirectToUrl ¶
func RedirectToUrl(w http.ResponseWriter, r *http.Request, url string)
func RenderError ¶
Types ¶
type CsrfProtection ¶
type CsrfProtection int
const ( CsrfDisabled CsrfProtection = iota CsrfPerRequest CsrfPerSession )
type RenderOpt ¶
type RenderOpt func(cfg *renderCfg)
func RenderWithContentType ¶
func RenderWithLayoutFile ¶
func RenderWithStatusCode ¶
func RenderWithTemplateName ¶
func RenderWithoutBuffer ¶
func RenderWithoutBuffer() RenderOpt
type Session ¶
type Session interface { Set(key string, value any) Get(key string) (any, bool) GetString(key string) string AddFlashMessage(msg string) AddFlashSuccess(msg string) AddFlashWarning(msg string) AddFlashError(msg string) Delete(key string) Clear() }
func CurrentSession ¶
type SessionStore ¶
type SessionStore interface {
Wrap(fn http.HandlerFunc) http.HandlerFunc
}
func NewSessionStore ¶
func NewSessionStore(cookieName, authKey, encKey string, csrf CsrfProtection) (SessionStore, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.