context

package
Version: v0.9.71 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2016 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIContexter

func APIContexter() macaron.Handler

func Contexter

func Contexter() macaron.Handler

Contexter initializes a classic context for a request.

func GitHookService

func GitHookService() macaron.Handler

GitHookService checks if repository Git hooks service has been enabled.

func HandleOrgAssignment

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

func OrgAssignment

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

func RepoAssignment

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

func RepoRef

func RepoRef() macaron.Handler

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

func RequireRepoAdmin

func RequireRepoAdmin() macaron.Handler

func RequireRepoWriter

func RequireRepoWriter() macaron.Handler

func RetrieveBaseRepo

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

func Toggle

func Toggle(options *ToggleOptions) macaron.Handler

Types

type APIContext

type APIContext struct {
	*Context
	Org *APIOrganization
}

func (*APIContext) Error

func (ctx *APIContext) Error(status int, title string, obj interface{})

Error responses error message to client with given message. If status is 500, also it prints error to log.

func (*APIContext) SetLinkHeader

func (ctx *APIContext) SetLinkHeader(total, pageSize int)

SetLinkHeader sets pagination link header by given totol number and page size.

type APIOrganization added in v0.9.46

type APIOrganization struct {
	Organization *models.User
	Team         *models.Team
}

type Context

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

	Flash   *session.Flash
	Session session.Store

	User        *models.User
	IsSigned    bool
	IsBasicAuth bool

	Repo *Repository
	Org  *Organization
	// contains filtered or unexported fields
}

Context represents context of a request.

func (*Context) GetErrMsg

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) HandleError added in v0.9.60

func (ctx *Context) HandleError(title string, errck func(error) bool, err error, status int)

HandleError use error check function to determine if server should response as client input error or server internal error. It responses with given status code for client error, or error context description for logging purpose of server error.

func (*Context) HandleText

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

func (*Context) HasApiError

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

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

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

type Organization

type Organization 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
}

type PullRequest

type PullRequest struct {
	BaseRepo *models.Repository
	Allowed  bool
	SameRepo bool
	HeadInfo string // [<user>:]<branch>
}

type Repository

type Repository 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

	PullRequest *PullRequest
}

func (*Repository) HasAccess

func (r *Repository) HasAccess() bool

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

func (*Repository) IsAdmin

func (r *Repository) IsAdmin() bool

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

func (*Repository) IsOwner

func (r *Repository) IsOwner() bool

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

func (*Repository) IsWriter

func (r *Repository) IsWriter() bool

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

type ToggleOptions

type ToggleOptions struct {
	SignInRequired  bool
	SignOutRequired bool
	AdminRequired   bool
	DisableCSRF     bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL