Documentation
¶
Index ¶
- Constants
- func ContextWithUser(ctx context.Context, user User) context.Context
- func TypeFromString(raw string, t interface{}) error
- func TypeToString(t interface{}) (string, error)
- type App
- func (app App) Authenticate(destination string) mux.MiddlewareFunc
- func (app App) Cors() mux.MiddlewareFunc
- func (app App) Logging() mux.MiddlewareFunc
- func (app App) NewTemplatingEngine() TemplatingEngine
- func (app App) Recoverer(destination string) mux.MiddlewareFunc
- func (app App) RedirectIfAuthenticated(destination string) mux.MiddlewareFunc
- func (app App) ServeFiles(notFound http.Handler) http.Handler
- func (app App) StoreUserToContext() mux.MiddlewareFunc
- type FlashMessage
- type InMemoryUser
- type Locale
- type Session
- func (s Session) Delete(w http.ResponseWriter, r *http.Request, key string) error
- func (s Session) Destroy(w http.ResponseWriter, r *http.Request) error
- func (s Session) Flash(w http.ResponseWriter, r *http.Request, flashMessage FlashMessage) error
- func (s Session) Flashes(w http.ResponseWriter, r *http.Request) []FlashMessage
- func (s Session) Get(r *http.Request, key string) (string, error)
- func (s Session) GetUserID(r *http.Request) (string, error)
- func (s Session) GetUserLocale(r *http.Request) string
- func (s Session) IsGuest(r *http.Request) bool
- func (s Session) Put(w http.ResponseWriter, r *http.Request, key string, value string) error
- func (s Session) SetUserID(w http.ResponseWriter, r *http.Request, id string) error
- func (s Session) SetUserLocale(w http.ResponseWriter, r *http.Request, id string) error
- type TemplatingEngine
- type User
- type UserRepository
- type ViewHelperFunc
Constants ¶
View Source
const CORSAllowedMethods = "OPTIONS,HEAD,GET,POST,PUT,PATCH,DELETE"
View Source
const CORSAllowedOrigin = "*"
View Source
const ContentTypeHTML = "text/html; charset=utf-8"
View Source
const UserIDKey = "_user_id"
View Source
const UserLocaleKey = "_user_locale"
Variables ¶
This section is empty.
Functions ¶
func TypeFromString ¶
func TypeToString ¶
Types ¶
type App ¶
type App struct {
Logger *log.Logger
Router *mux.Router
Static fs.FS
StaticPrefix string
ViewFiles fs.FS
ViewHelpers []ViewHelperFunc
Session *Session
UserRepository UserRepository
Locale Locale
}
func (App) Authenticate ¶
func (app App) Authenticate(destination string) mux.MiddlewareFunc
func (App) Cors ¶
func (app App) Cors() mux.MiddlewareFunc
func (App) Logging ¶
func (app App) Logging() mux.MiddlewareFunc
func (App) NewTemplatingEngine ¶
func (app App) NewTemplatingEngine() TemplatingEngine
func (App) RedirectIfAuthenticated ¶
func (app App) RedirectIfAuthenticated(destination string) mux.MiddlewareFunc
func (App) StoreUserToContext ¶
func (app App) StoreUserToContext() mux.MiddlewareFunc
type FlashMessage ¶
func NewFlash ¶
func NewFlash(message string) FlashMessage
type InMemoryUser ¶
func (InMemoryUser) GetID ¶
func (u InMemoryUser) GetID() string
type Locale ¶
type Session ¶
func NewSession ¶
NewSession returns new session with requested store
func (Session) Flash ¶
func (s Session) Flash(w http.ResponseWriter, r *http.Request, flashMessage FlashMessage) error
func (Session) Flashes ¶
func (s Session) Flashes(w http.ResponseWriter, r *http.Request) []FlashMessage
func (Session) SetUserLocale ¶
type TemplatingEngine ¶
type TemplatingEngine interface {
Render(w http.ResponseWriter, r *http.Request, patterns ...string)
Set(key string, data interface{}) TemplatingEngine
SetError(errorKey, description string) TemplatingEngine
GetErrors() map[string]string
}
type UserRepository ¶
type UserRepository interface {
Authenticate(w http.ResponseWriter, r *http.Request) (User, error)
GetUserByID(id string) (User, error)
}
func NewInMemoryUserRepository ¶
func NewInMemoryUserRepository(users []InMemoryUser) UserRepository
type ViewHelperFunc ¶
type ViewHelperFunc func(w http.ResponseWriter, r *http.Request) (string, interface{})
Source Files
¶
Click to show internal directories.
Click to hide internal directories.