contextmodel

package
v0.0.0-cloud Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReqContext

type ReqContext struct {
	*web.Context
	*user.SignedInUser
	UserToken *usertoken.UserToken

	IsSignedIn     bool
	IsRenderCall   bool
	AllowAnonymous bool
	SkipCache      bool
	Logger         log.Logger
	// RequestNonce is a cryptographic request identifier for use with Content Security Policy.
	RequestNonce          string
	IsPublicDashboardView bool

	PerfmonTimer   prometheus.Summary
	LookupTokenErr error
}

func (*ReqContext) Handle

func (ctx *ReqContext) Handle(cfg *setting.Cfg, status int, title string, err error)

Handle handles and logs error by given status.

func (*ReqContext) HasHelpFlag

func (ctx *ReqContext) HasHelpFlag(flag user.HelpFlags1) bool

func (*ReqContext) HasUserRole

func (ctx *ReqContext) HasUserRole(role org.RoleType) bool

func (*ReqContext) IsApiRequest

func (ctx *ReqContext) IsApiRequest() bool

func (*ReqContext) JsonApiErr

func (ctx *ReqContext) JsonApiErr(status int, message string, err error)

func (*ReqContext) QueryBoolWithDefault

func (ctx *ReqContext) QueryBoolWithDefault(field string, d bool) bool

QueryBoolWithDefault extracts a value from the request query params and applies a bool default if not present.

func (*ReqContext) TimeRequest

func (ctx *ReqContext) TimeRequest(timer prometheus.Summary)

func (*ReqContext) WriteErr

func (ctx *ReqContext) WriteErr(err error)

WriteErr writes an error response based on errutil.Error. If provided error is not errutil.Error a 500 response is written.

func (*ReqContext) WriteErrOrFallback

func (ctx *ReqContext) WriteErrOrFallback(status int, message string, err error)

WriteErrOrFallback uses the information in an errutil.Error if available and otherwise falls back to the status and message provided as arguments.

Jump to

Keyboard shortcuts

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