context

package
v0.0.0-...-d0e669d Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Info    = "info"
	Success = "success"
	Warning = "warning"
	Error   = "error"
)

Variables

This section is empty.

Functions

func APIEndpoint

func APIEndpoint(ctx Context)

func Contexter

func Contexter() flamego.Handler

Contexter initializes a classic context for a request.

func Toggle

func Toggle(options *ToggleOptions) flamego.Handler

Types

type Context

type Context struct {
	flamego.Context

	Data     template.Data
	Session  session.Session
	Template template.Template

	User     *db.User
	IsLogged bool
}

Context represents context of a request.

func (*Context) HasError

func (c *Context) HasError() bool

HasError returns true if error occurs in form validation.

func (*Context) JSON

func (c *Context) JSON(data interface{}) error

func (*Context) JSONError

func (c *Context) JSONError(errorCode int, message string) error

func (*Context) Refresh

func (c *Context) Refresh()

func (*Context) ServerError

func (c *Context) ServerError() error

func (*Context) SetError

func (c *Context) SetError(err error, f ...interface{})

func (Context) SetErrorFlash

func (c Context) SetErrorFlash(message string, tip ...string)

func (Context) SetInfoFlash

func (c Context) SetInfoFlash(message string, tip ...string)

func (*Context) SetInternalError

func (c *Context) SetInternalError(f ...interface{})

func (Context) SetInternalErrorFlash

func (c Context) SetInternalErrorFlash()

func (Context) SetSuccessFlash

func (c Context) SetSuccessFlash(message string, tip ...string)

func (*Context) SetTitle

func (c *Context) SetTitle(title string)

func (Context) SetWarningFlash

func (c Context) SetWarningFlash(message string, tip ...string)

func (*Context) Success

func (c *Context) Success(templateName string)

Success renders HTML template with given name with 200 OK status code.

type EndpointType

type EndpointType string
const (
	EndpointAPI EndpointType = "api"
	EndpointWeb EndpointType = "web"
)

func (EndpointType) IsAPI

func (e EndpointType) IsAPI() bool

func (EndpointType) IsWeb

func (e EndpointType) IsWeb() bool

type Flash

type Flash struct {
	Type     FlashType
	Message  string
	FlashTip string
}

type FlashType

type FlashType string

type ToggleOptions

type ToggleOptions struct {
	UserSignInRequired  bool
	UserSignOutRequired bool
}

Jump to

Keyboard shortcuts

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