middleware

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2016 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoSignIn added in v0.6.5

func AutoSignIn(ctx *Context) (bool, error)

AutoSignIn reads cookie and try to auto-login.

func Contexter added in v0.5.0

func Contexter() macaron.Handler

Contexter initializes a classic context for a request.

func GitHookService added in v0.5.5

func GitHookService() macaron.Handler

GitHookService checks if repository Git hooks service has been enabled.

func HandleOrgAssignment added in v0.7.22

func HandleOrgAssignment(ctx *Context, args ...bool)

func OrgAssignment added in v0.5.0

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

func RepoAssignment

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

func RepoRef added in v0.5.8

func RepoRef() macaron.Handler

RepoRef handles repository reference name including those contain `/`.

func RequireRepoAdmin added in v0.6.5

func RequireRepoAdmin() macaron.Handler

func RequireRepoWriter added in v0.9.0

func RequireRepoWriter() macaron.Handler

func RetrieveBaseRepo added in v0.6.9

func RetrieveBaseRepo(ctx *Context, repo *models.Repository)

func Toggle

func Toggle(options *ToggleOptions) macaron.Handler

Types

type Context

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

	Flash   *session.Flash
	Session session.Store

	User        *models.User
	IsSigned    bool
	IsBasicAuth bool

	Repo *RepoContext

	Org struct {
		IsOwner      bool
		IsMember     bool
		IsTeamMember bool // Is member of team.
		IsTeamAdmin  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) APIError added in v0.7.0

func (ctx *Context) APIError(status int, title string, obj interface{})

APIError logs error with title if status is 500.

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) HandleText added in v0.6.3

func (ctx *Context) HandleText(status int, title string)

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) HasValue added in v0.6.3

func (ctx *Context) HasValue(name string) bool

HasValue returns true if value of given name exists.

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{})

type RepoContext added in v0.6.0

type RepoContext struct {
	AccessMode   models.AccessMode
	IsWatching   bool
	IsViewBranch bool
	IsViewTag    bool
	IsViewCommit bool
	Repository   *models.Repository
	Owner        *models.User
	Commit       *git.Commit
	Tag          *git.Tag
	GitRepo      *git.Repository
	BranchName   string
	TagName      string
	TreeName     string
	CommitID     string
	RepoLink     string
	CloneLink    models.CloneLink
	CommitsCount int64
	Mirror       *models.Mirror
}

func (*RepoContext) HasAccess added in v0.6.0

func (r *RepoContext) HasAccess() bool

HasAccess returns true if the current user has at least read access for this repository

func (*RepoContext) IsAdmin added in v0.6.5

func (r *RepoContext) IsAdmin() bool

IsAdmin returns true if current user has admin or higher access of repository.

func (*RepoContext) IsOwner added in v0.6.0

func (r *RepoContext) IsOwner() bool

IsOwner returns true if current user is the owner of repository.

func (*RepoContext) IsWriter added in v0.9.0

func (r *RepoContext) IsWriter() bool

IsWriter returns true if current user has write or higher access of repository.

type ToggleOptions

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

Jump to

Keyboard shortcuts

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