middleware

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2014 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contexter added in v0.5.0

func Contexter() macaron.Handler

Contexter initializes a classic context for a request.

func OrgAssignment added in v0.5.0

func OrgAssignment(redirect bool, args ...bool) macaron.Handler

func RepoAssignment

func RepoAssignment(redirect bool, args ...bool) macaron.Handler

func RequireTrueOwner added in v0.5.0

func RequireTrueOwner() macaron.Handler

func Toggle

func Toggle(options *ToggleOptions) macaron.Handler

Types

type Context

type Context struct {
	*macaron.Context
	i18n.Locale
	Cache cache.Cache

	Flash   *session.Flash
	Session session.Store

	User     *models.User
	IsSigned bool

	Repo struct {
		IsOwner     bool
		IsTrueOwner bool
		IsWatching  bool
		IsBranch    bool
		IsTag       bool
		IsCommit    bool
		IsAdmin     bool // Current user is admin level.
		HasAccess   bool
		Repository  *models.Repository
		Owner       *models.User
		Commit      *git.Commit
		Tag         *git.Tag
		GitRepo     *git.Repository
		BranchName  string
		TagName     string
		CommitId    string
		RepoLink    string
		CloneLink   struct {
			SSH   string
			HTTPS string
			Git   string
		}
		CommitsCount int
		Mirror       *models.Mirror
	}

	Org struct {
		IsOwner      bool
		IsMember     bool
		IsAdminTeam  bool // In owner team or team that has admin permission level.
		Organization *models.User
		OrgLink      string

		Team *models.Team
	}
	// contains filtered or unexported fields
}

Context represents context of a request.

func (*Context) GetErrMsg added in v0.4.0

func (ctx *Context) GetErrMsg() string

func (*Context) HTML

func (ctx *Context) HTML(status int, name base.TplName)

HTML calls Context.HTML and converts template name to string.

func (*Context) Handle

func (ctx *Context) Handle(status int, title string, err error)

Handle handles and logs error by given status.

func (*Context) HasApiError added in v0.4.0

func (ctx *Context) HasApiError() bool

HasError returns true if error occurs in form validation.

func (*Context) HasError

func (ctx *Context) HasError() bool

HasError returns true if error occurs in form validation.

func (*Context) Query

func (ctx *Context) Query(name string) string

Query querys form parameter.

func (*Context) RenderWithErr

func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form interface{})

RenderWithErr used for page has form validation but need to prompt error to users.

func (*Context) ServeContent added in v0.3.0

func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{})

func (*Context) ServeFile added in v0.3.0

func (ctx *Context) ServeFile(file string, names ...string)

type ToggleOptions

type ToggleOptions struct {
	SignInRequire  bool
	SignOutRequire bool
	AdminRequire   bool
	DisableCsrf    bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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