{"modulePath":"github.com/generaltso/gitea","version":"v1.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package context\n\n## Functions\n\n```go\nfunc APIContexter() macaron.Handler\n```\nAPIContexter returns apicontext as macaron middleware\n\n```go\nfunc CheckAnyUnit(unitTypes ...models.UnitType) macaron.Handler\n```\nCheckAnyUnit will check whether any of the unit types are enabled\n\n```go\nfunc CheckUnit(unitType models.UnitType) macaron.Handler\n```\nCheckUnit will check whether\n\n```go\nfunc ComposeGoGetImport(owner, repo string) string\n```\nComposeGoGetImport returns go-get-import meta content.\n\n```go\nfunc Contexter() macaron.Handler\n```\nContexter initializes a classic context for a request.\n\n```go\nfunc EarlyResponseForGoGetMeta(ctx *Context)\n```\nEarlyResponseForGoGetMeta responses appropriate go-get meta with status 200 if user does not have actual access to the requested repository, or the owner or repository does not exist at all. This is particular a workaround for \"go get\" command which does not respect .netrc file.\n\n```go\nfunc GitHookService() macaron.Handler\n```\nGitHookService checks if repository Git hooks service has been enabled.\n\n```go\nfunc HandleOrgAssignment(ctx *Context, args ...bool)\n```\nHandleOrgAssignment handles organization assignment\n\n```go\nfunc LoadRepoUnits() macaron.Handler\n```\nLoadRepoUnits loads repsitory's units, it should be called after repository and user loaded\n\n```go\nfunc OrgAssignment(args ...bool) macaron.Handler\n```\nOrgAssignment returns a macaron middleware to handle organization assignment\n\n```go\nfunc RedirectToRepo(ctx *Context, redirectRepoID int64)\n```\nRedirectToRepo redirect to a differently-named repository\n\n```go\nfunc ReferencesGitRepo() macaron.Handler\n```\nReferencesGitRepo injects the GitRepo into the Context\n\n```go\nfunc RepoAssignment() macaron.Handler\n```\nRepoAssignment returns a macaron to handle repository assignment\n\n```go\nfunc RepoIDAssignment() macaron.Handler\n```\nRepoIDAssignment returns an macaron handler which assigns the repo to the context.\n\n```go\nfunc RepoRef() macaron.Handler\n```\nRepoRef handles repository reference name including those contain \\`/\\`.\n\n```go\nfunc RequireRepoAdmin() macaron.Handler\n```\nRequireRepoAdmin returns a macaron middleware for requiring repository admin permission\n\n```go\nfunc RequireRepoWriter() macaron.Handler\n```\nRequireRepoWriter returns a macaron middleware for requiring repository write permission\n\n```go\nfunc RetrieveBaseRepo(ctx *Context, repo *models.Repository)\n```\nRetrieveBaseRepo retrieves base repository\n\n```go\nfunc Toggle(options *ToggleOptions) macaron.Handler\n```\nToggle returns toggle options as middleware\n\n```go\nfunc UnitTypes() macaron.Handler\n```\nUnitTypes returns a macaron middleware to set unit types to context variables.\n\n## Types\n\n```go\ntype APIContext struct {\n\t*Context\n\tOrg *APIOrganization\n}\n```\nAPIContext is a specific macaron context for API service\n\n```go\nfunc (ctx *APIContext) Error(status int, title string, obj interface{})\n```\nError responses error message to client with given message. If status is 500, also it prints error to log.\n\n```go\nfunc (ctx *APIContext) SetLinkHeader(total, pageSize int)\n```\nSetLinkHeader sets pagination link header by given total number and page size.\n\n```go\ntype APIEmpty struct{}\n```\nAPIEmpty is an empty response swagger:response empty\n\n```go\ntype APIError struct {\n\tMessage string `json:\"message\"`\n\tURL     string `json:\"url\"`\n}\n```\nAPIError is error format response swagger:response error\n\n```go\ntype APIForbiddenError struct {\n\tAPIError\n}\n```\nAPIForbiddenError is a forbidden error response swagger:response forbidden\n\n```go\ntype APINotFound struct{}\n```\nAPINotFound is a not found empty response swagger:response notFound\n\n```go\ntype APIOrganization struct {\n\tOrganization *models.User\n\tTeam         *models.Team\n}\n```\nAPIOrganization contains organization and team\n\n```go\ntype APIRedirect struct{}\n```\nAPIRedirect is a redirect response swagger:response redirect\n\n```go\ntype APIValidationError struct {\n\tMessage string `json:\"message\"`\n\tURL     string `json:\"url\"`\n}\n```\nAPIValidationError is error format response related to input validation swagger:response validationError\n\n```go\ntype Context struct {\n\t*macaron.Context\n\tCache cache.Cache\n\n\tFlash   *session.Flash\n\tSession session.Store\n\n\tLink        string // current request URL\n\tUser        *models.User\n\tIsSigned    bool\n\tIsBasicAuth bool\n\n\tRepo *Repository\n\tOrg  *Organization\n\t// contains filtered or unexported fields\n}\n```\nContext represents context of a request.\n\n```go\nfunc (ctx *Context) GetErrMsg() string\n```\nGetErrMsg returns error message\n\n```go\nfunc (ctx *Context) HTML(status int, name base.TplName)\n```\nHTML calls Context.HTML and converts template name to string.\n\n```go\nfunc (ctx *Context) Handle(status int, title string, err error)\n```\nHandle handles and logs error by given status.\n\n```go\nfunc (ctx *Context) HandleText(status int, title string)\n```\nHandleText handles HTTP status code\n\n```go\nfunc (ctx *Context) HasAPIError() bool\n```\nHasAPIError returns true if error occurs in form validation.\n\n```go\nfunc (ctx *Context) HasError() bool\n```\nHasError returns true if error occurs in form validation.\n\n```go\nfunc (ctx *Context) HasValue(name string) bool\n```\nHasValue returns true if value of given name exists.\n\n```go\nfunc (ctx *Context) NotFoundOrServerError(title string, errck func(error) bool, err error)\n```\nNotFoundOrServerError use error check function to determine if the error is about not found. It responses with 404 status code for not found error, or error context description for logging purpose of 500 server error.\n\n```go\nfunc (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form interface{})\n```\nRenderWithErr used for page has form validation but need to prompt error to users.\n\n```go\nfunc (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{})\n```\nServeContent serves content to http request\n\n```go\ntype Organization struct {\n\tIsOwner      bool\n\tIsMember     bool\n\tIsTeamMember bool // Is member of team.\n\tIsTeamAdmin  bool // In owner team or team that has admin permission level.\n\tOrganization *models.User\n\tOrgLink      string\n\n\tTeam *models.Team\n}\n```\nOrganization contains organization context\n\n```go\ntype PullRequest struct {\n\tBaseRepo *models.Repository\n\tAllowed  bool\n\tSameRepo bool\n\tHeadInfo string // [\u003cuser\u003e:]\u003cbranch\u003e\n}\n```\nPullRequest contains informations to make a pull request\n\n```go\ntype Repository struct {\n\tAccessMode   models.AccessMode\n\tIsWatching   bool\n\tIsViewBranch bool\n\tIsViewTag    bool\n\tIsViewCommit bool\n\tRepository   *models.Repository\n\tOwner        *models.User\n\tCommit       *git.Commit\n\tTag          *git.Tag\n\tGitRepo      *git.Repository\n\tBranchName   string\n\tTagName      string\n\tTreePath     string\n\tCommitID     string\n\tRepoLink     string\n\tCloneLink    models.CloneLink\n\tCommitsCount int64\n\tMirror       *models.Mirror\n\n\tPullRequest *PullRequest\n}\n```\nRepository contains information to operate a repository\n\n```go\nfunc (r *Repository) CanCommitToBranch() (bool, error)\n```\nCanCommitToBranch returns true if repository is editable and user has proper access level\n\n\tand branch is not protected\n\n```go\nfunc (r *Repository) CanEnableEditor() bool\n```\nCanEnableEditor returns true if repository is editable and user has proper access level.\n\n```go\nfunc (r *Repository) GetEditorconfig() (*editorconfig.Editorconfig, error)\n```\nGetEditorconfig returns the .editorconfig definition if found in the HEAD of the default repo branch.\n\n```go\nfunc (r *Repository) HasAccess() bool\n```\nHasAccess returns true if the current user has at least read access for this repository\n\n```go\nfunc (r *Repository) IsAdmin() bool\n```\nIsAdmin returns true if current user has admin or higher access of repository.\n\n```go\nfunc (r *Repository) IsOwner() bool\n```\nIsOwner returns true if current user is the owner of repository.\n\n```go\nfunc (r *Repository) IsWriter() bool\n```\nIsWriter returns true if current user has write or higher access of repository.\n\n```go\ntype ToggleOptions struct {\n\tSignInRequired  bool\n\tSignOutRequired bool\n\tAdminRequired   bool\n\tDisableCSRF     bool\n}\n```\nToggleOptions contains required or check options\n\n","path":"github.com/generaltso/gitea/modules/context","name":"context","synopsis":"","isRedistributable":true}
