{"modulePath":"github.com/devfans/gogs","version":"v0.11.53","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package context\n\n## Constants\n\n```go\nconst DOC_URL = \"https://github.com/gogs/go-gogs-client/wiki\"\n```\nFIXME: move to github.com/gogs/go-gogs-client\n\n## Functions\n\n```go\nfunc APIContexter() macaron.Handler\n```\n\n```go\nfunc Contexter() macaron.Handler\n```\nContexter initializes a classic context for a request.\n\n```go\nfunc GitHookService() macaron.Handler\n```\nGitHookService checks if repository Git hooks service has been enabled.\n\n```go\nfunc HandleOrgAssignment(c *Context, args ...bool)\n```\n\n```go\nfunc OrgAssignment(args ...bool) macaron.Handler\n```\n\n```go\nfunc RepoAssignment(pages ...bool) macaron.Handler\n```\n\\[0]: issues, \\[1]: wiki\n\n```go\nfunc RepoRef() macaron.Handler\n```\nRepoRef handles repository reference name including those contain \\`/\\`.\n\n```go\nfunc RequireRepoAdmin() macaron.Handler\n```\n\n```go\nfunc RequireRepoWriter() macaron.Handler\n```\n\n```go\nfunc Toggle(options *ToggleOptions) macaron.Handler\n```\n\n## Types\n\n```go\ntype APIContext struct {\n\t*Context\n\tOrg *APIOrganization\n}\n```\n\n```go\nfunc (c *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 (c *APIContext) SetLinkHeader(total, pageSize int)\n```\nSetLinkHeader sets pagination link header by given totol number and page size.\n\n```go\ntype APIOrganization struct {\n\tOrganization *models.User\n\tTeam         *models.Team\n}\n```\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\tIsLogged    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 (c *Context) FormErr(names ...string)\n```\nFormErr sets \"Err\\_xxx\" field in template data.\n\n```go\nfunc (c *Context) GetErrMsg() string\n```\n\n```go\nfunc (c *Context) HTML(status int, name string)\n```\nHTML responses template with given status.\n\n```go\nfunc (c *Context) Handle(status int, title string, err error)\n```\nHandle handles and logs error by given status.\n\n```go\nfunc (c *Context) HandleText(status int, title string)\n```\n\n```go\nfunc (c *Context) HasApiError() bool\n```\nHasError returns true if error occurs in form validation.\n\n```go\nfunc (c *Context) HasError() bool\n```\nHasError returns true if error occurs in form validation.\n\n```go\nfunc (c *Context) HasValue(name string) bool\n```\nHasValue returns true if value of given name exists.\n\n```go\nfunc (c *Context) JSONSuccess(data interface{})\n```\nJSONSuccess responses JSON with status http.StatusOK.\n\n```go\nfunc (c *Context) NotFound()\n```\nNotFound renders the 404 page.\n\n```go\nfunc (c *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 (c *Context) PageIs(name string)\n```\nPageIs sets \"PageIsxxx\" field in template data.\n\n```go\nfunc (c *Context) RenderWithErr(msg, tpl string, f interface{})\n```\nRenderWithErr used for page has form validation but need to prompt error to users.\n\n```go\nfunc (c *Context) Require(name string)\n```\nRequire sets \"Requirexxx\" field in template data.\n\n```go\nfunc (c *Context) RequireHighlightJS()\n```\n\n```go\nfunc (c *Context) RequireSimpleMDE()\n```\n\n```go\nfunc (c *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{})\n```\n\n```go\nfunc (c *Context) ServerError(title string, err error)\n```\nServerError renders the 500 page.\n\n```go\nfunc (c *Context) SubURLRedirect(location string, status ...int)\n```\nSubURLRedirect responses redirection wtih given location and status. It prepends setting.AppSubURL to the location string.\n\n```go\nfunc (c *Context) Success(name string)\n```\nSuccess responses template with status http.StatusOK.\n\n```go\nfunc (c *Context) Title(locale string)\n```\nTitle sets \"Title\" field in template data.\n\n```go\nfunc (c *Context) UserID() int64\n```\nUserID returns ID of current logged in user. It returns 0 if visitor is anonymous.\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```\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```\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```\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\nfunc (r *Repository) PullRequestURL(baseBranch, headBranch string) string\n```\nPullRequestURL returns URL for composing a pull request. This function does not check if the repository can actually compose a pull request.\n\n```go\ntype ToggleOptions struct {\n\tSignInRequired  bool\n\tSignOutRequired bool\n\tAdminRequired   bool\n\tDisableCSRF     bool\n}\n```\n\n","path":"github.com/devfans/gogs/pkg/context","name":"context","synopsis":"","isRedistributable":true}
