Documentation
¶
Index ¶
- Variables
- type Accepts
- type Controller
- func (c *Controller) Accepts() Accepts
- func (c *Controller) AddErrorFlash(msg any)
- func (c *Controller) AddFlash(key string, value any)
- func (c *Controller) AddNoticeFlash(msg any)
- func (c *Controller) AddSuccessFlash(msg any)
- func (c *Controller) AddWarningFlash(msg any)
- func (c *Controller) After_ZZZZ_EnsureRender()
- func (c *Controller) BadRequest()
- func (c *Controller) Before_0000_SetupRequest(r *http.Request, w http.ResponseWriter, a *lazyassets.Storage, ...)
- func (c *Controller) CSRFToken() string
- func (c *Controller) FillWithParams(model string, data any) error
- func (c *Controller) Flashes(key ...string) []FlashMessager
- func (c *Controller) FlashesByType() map[string][]any
- func (c *Controller) Forbidden()
- func (c *Controller) Gen_Params() *Params
- func (c *Controller) HandleError(err error)
- func (c *Controller) HeaderSet(key string, value string)
- func (c *Controller) NoContent()
- func (c *Controller) ParamsGet(name string) string
- func (c *Controller) ParamsGetBool(name string) bool
- func (c *Controller) ParamsGetInt(name string) int
- func (c *Controller) ParamsGetUint(name string) uint
- func (c *Controller) ParamsIsPresent(name string) bool
- func (c *Controller) PathTo(args ...any) string
- func (c *Controller) Redirect(url string, code ...int)
- func (c *Controller) RedirectBack(fallback string, code ...int)
- func (c *Controller) RedirectTo(args ...any)
- func (c *Controller) Render()
- func (c *Controller) RenderContent(content string)
- func (c *Controller) SendFile(filename string, data io.Reader)
- func (c *Controller) SessionDelete(key string)
- func (c *Controller) SessionGet(key string) *lazysupport.Value
- func (c *Controller) SessionSet(key string, value any)
- func (c *Controller) SessionValues() map[any]any
- func (c *Controller) TurboStream(streams ...io.WriterTo)
- func (c *Controller) URLParam(s string) (string, bool)
- func (c *Controller) URLParamInt(s string) (int, bool)
- func (c *Controller) URLParamUint(s string) (uint, bool)
- func (c *Controller) UnprocessableEntity()
- func (v *Controller) ViewData(val any)
- func (v *Controller) ViewObj(val any)
- func (v *Controller) ViewVar(name string, val any)
- func (c *Controller) Wants(mimes ...string) bool
- func (c *Controller) WantsHTML() bool
- func (c *Controller) WantsJSON() bool
- func (c *Controller) WantsTurbo() bool
- func (c *Controller) WithParam(name string, fn func(string))
- func (c *Controller) WithParamBool(name string, fn func(bool))
- func (c *Controller) WithParamInt(name string, fn func(int))
- func (c *Controller) WithParamUint(name string, fn func(uint))
- type ErrOpts
- type Error
- type ErrorWithHandler
- type File
- type Flash
- type FlashMessage
- type FlashMessager
- type MimeType
- type MimeTypeParams
- type Params
- func (p *Params) File(name string) *File
- func (p *Params) Get(name string) string
- func (p *Params) GetBool(name string) (value bool, ok bool)
- func (p *Params) GetInt(name string) int
- func (p *Params) GetString(name string) string
- func (p *Params) GetUint(name string) uint
- func (p *Params) IsPresent(name string) bool
- func (p *Params) With(name string, fn func(string))
- func (p *Params) WithFile(name string, fn func(*File))
- type RedirectError
- type Session
- type TemplateObj
- type TemplateVar
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBadRequest = &Error{Code: 400}
View Source
var (
ErrBodyAlreadySent error = fmt.Errorf("body already sent")
)
View Source
var ErrForbidden = &Error{Code: 403}
View Source
var ErrNotFound = &Error{Code: 404}
View Source
var ErrUnprocessableEntity = &Error{Code: 422}
View Source
var FlashError = "error" // Red
View Source
var FlashNotice = "notice" // Blue
View Source
var FlashSuccess = "success" // Green
View Source
var FlashWarning = "warning" // Yellow
View Source
var MaxFormSize int64 = 10 * 1024 * 1024
View Source
var SessionName = "lazy_session"
View Source
var Store = sessions.NewCookieStore([]byte("Tjz@-QNkekP2KH8oF9A_GNssbwvftXqv"))
Functions ¶
This section is empty.
Types ¶
type Accepts ¶
type Accepts map[MimeType]MimeTypeParams
type Controller ¶
type Controller struct {
Request *http.Request
ResponseWriter http.ResponseWriter
ControllerName string
ActionName string
Namespace string
ViewVariables []any
Layout string
W http.ResponseWriter
// contains filtered or unexported fields
}
func (*Controller) Accepts ¶
func (c *Controller) Accepts() Accepts
func (*Controller) AddErrorFlash ¶
func (c *Controller) AddErrorFlash(msg any)
func (*Controller) AddFlash ¶
func (c *Controller) AddFlash(key string, value any)
func (*Controller) AddNoticeFlash ¶
func (c *Controller) AddNoticeFlash(msg any)
func (*Controller) AddSuccessFlash ¶
func (c *Controller) AddSuccessFlash(msg any)
func (*Controller) AddWarningFlash ¶
func (c *Controller) AddWarningFlash(msg any)
func (*Controller) After_ZZZZ_EnsureRender ¶
func (c *Controller) After_ZZZZ_EnsureRender()
func (*Controller) BadRequest ¶
func (c *Controller) BadRequest()
func (*Controller) Before_0000_SetupRequest ¶
func (c *Controller) Before_0000_SetupRequest(r *http.Request, w http.ResponseWriter, a *lazyassets.Storage, route *lazydispatch.Route, dispatcher *lazydispatch.Dispatcher, views *lazyview.Views)
func (*Controller) CSRFToken ¶
func (c *Controller) CSRFToken() string
func (*Controller) FillWithParams ¶
func (c *Controller) FillWithParams(model string, data any) error
func (*Controller) Flashes ¶
func (c *Controller) Flashes(key ...string) []FlashMessager
func (*Controller) FlashesByType ¶
func (c *Controller) FlashesByType() map[string][]any
func (*Controller) Forbidden ¶
func (c *Controller) Forbidden()
func (*Controller) Gen_Params ¶
func (c *Controller) Gen_Params() *Params
func (*Controller) HandleError ¶
func (c *Controller) HandleError(err error)
func (*Controller) HeaderSet ¶
func (c *Controller) HeaderSet(key string, value string)
func (*Controller) NoContent ¶
func (c *Controller) NoContent()
func (*Controller) ParamsGet ¶
func (c *Controller) ParamsGet(name string) string
func (*Controller) ParamsGetBool ¶
func (c *Controller) ParamsGetBool(name string) bool
func (*Controller) ParamsGetInt ¶
func (c *Controller) ParamsGetInt(name string) int
func (*Controller) ParamsGetUint ¶
func (c *Controller) ParamsGetUint(name string) uint
func (*Controller) ParamsIsPresent ¶
func (c *Controller) ParamsIsPresent(name string) bool
func (*Controller) PathTo ¶
func (c *Controller) PathTo(args ...any) string
func (*Controller) Redirect ¶
func (c *Controller) Redirect(url string, code ...int)
func (*Controller) RedirectBack ¶
func (c *Controller) RedirectBack(fallback string, code ...int)
func (*Controller) RedirectTo ¶
func (c *Controller) RedirectTo(args ...any)
func (*Controller) Render ¶
func (c *Controller) Render()
func (*Controller) RenderContent ¶
func (c *Controller) RenderContent(content string)
func (*Controller) SessionDelete ¶
func (c *Controller) SessionDelete(key string)
func (*Controller) SessionGet ¶
func (c *Controller) SessionGet(key string) *lazysupport.Value
func (*Controller) SessionSet ¶
func (c *Controller) SessionSet(key string, value any)
func (*Controller) SessionValues ¶
func (c *Controller) SessionValues() map[any]any
SessionValues return all values in the session. Modifying the returned map may or may not work. Use SessionSet or SessionDelete instead.
func (*Controller) TurboStream ¶
func (c *Controller) TurboStream(streams ...io.WriterTo)
func (*Controller) URLParamInt ¶
func (c *Controller) URLParamInt(s string) (int, bool)
func (*Controller) URLParamUint ¶
func (c *Controller) URLParamUint(s string) (uint, bool)
func (*Controller) UnprocessableEntity ¶
func (c *Controller) UnprocessableEntity()
func (*Controller) ViewData ¶
func (v *Controller) ViewData(val any)
func (*Controller) ViewObj ¶
func (v *Controller) ViewObj(val any)
func (*Controller) ViewVar ¶
func (v *Controller) ViewVar(name string, val any)
func (*Controller) Wants ¶
func (c *Controller) Wants(mimes ...string) bool
func (*Controller) WantsHTML ¶
func (c *Controller) WantsHTML() bool
func (*Controller) WantsJSON ¶
func (c *Controller) WantsJSON() bool
func (*Controller) WantsTurbo ¶
func (c *Controller) WantsTurbo() bool
func (*Controller) WithParam ¶
func (c *Controller) WithParam(name string, fn func(string))
func (*Controller) WithParamBool ¶
func (c *Controller) WithParamBool(name string, fn func(bool))
func (*Controller) WithParamInt ¶
func (c *Controller) WithParamInt(name string, fn func(int))
func (*Controller) WithParamUint ¶
func (c *Controller) WithParamUint(name string, fn func(uint))
type Error ¶
type Error struct {
// Location is the destination of the error
// If set, lazydispatch will:
// * Set the Location header
// * Default the http status code to 302
// * Set error.Error() as a flash message
Location string
// Code is the http status code to return
Code int
// Raise is a flag to raise the error as exception after sending the resposne to the client
Raise bool
// Public is a flag to indicate if the error is public
// If set, the user will see the details of the error message
// Otherwise, the user will see a generic error message
// NOTE: This only applies to environments that are not development or tests
Public bool
// NoFlash ensure that a flash is not generated to the user
NoFlash bool
ErrTitle string
ErrMessage string
// contains filtered or unexported fields
}
Error represents a generic error
func NewRedirectErrorf ¶
func NewError(offset int, err error) *Error {
return &Error{
error: lazysupport.NewError(offset+1, err),
}
}
type ErrorWithHandler ¶
type FlashMessage ¶
func (FlashMessage) Message ¶
func (f FlashMessage) Message() string
func (FlashMessage) Title ¶
func (f FlashMessage) Title() string
type FlashMessager ¶
type MimeTypeParams ¶
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
type RedirectError ¶
func (*RedirectError) Error ¶
func (e *RedirectError) Error() string
func (*RedirectError) ServeHTTP ¶
func (e *RedirectError) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Session ¶
type Session Controller
type TemplateObj ¶
type TemplateObj struct {
// contains filtered or unexported fields
}
func Obj ¶
func Obj(value any) TemplateObj
type TemplateVar ¶
type TemplateVar struct {
// contains filtered or unexported fields
}
func Var ¶
func Var(key string, value any) TemplateVar
Click to show internal directories.
Click to hide internal directories.