Documentation ¶
Index ¶
- Constants
- func APIContexter() macaron.Handler
- func Contexter() macaron.Handler
- func GitHookService() macaron.Handler
- func HandleOrgAssignment(c *Context, args ...bool)
- func InjectParamsUser() macaron.Handler
- func OrgAssignment(args ...bool) macaron.Handler
- func RepoAssignment(pages ...bool) macaron.Handler
- func RepoRef() macaron.Handler
- func RequireRepoAdmin() macaron.Handler
- func RequireRepoWriter() macaron.Handler
- func Toggle(options *ToggleOptions) macaron.Handler
- type APIContext
- func (c *APIContext) Error(status int, title string, obj interface{})
- func (c *APIContext) NoContent()
- func (c *APIContext) NotFound()
- func (c *APIContext) NotFoundOrServerError(title string, errck func(error) bool, err error)
- func (c *APIContext) ServerError(title string, err error)
- func (c *APIContext) SetLinkHeader(total, pageSize int)
- type APIOrganization
- type Context
- func (c *Context) FormErr(names ...string)
- func (c *Context) GetErrMsg() string
- func (c *Context) HTML(status int, name string)
- func (c *Context) Handle(status int, title string, err error)
- func (c *Context) HandleText(status int, title string)
- func (c *Context) HasApiError() bool
- func (c *Context) HasError() bool
- func (c *Context) HasValue(name string) bool
- func (c *Context) JSONSuccess(data interface{})
- func (c *Context) NotFound()
- func (c *Context) NotFoundOrServerError(title string, errck func(error) bool, err error)
- func (c *Context) PageIs(name string)
- func (c *Context) RawRedirect(location string, status ...int)
- func (c *Context) Redirect(location string, status ...int)
- func (c *Context) RenderWithErr(msg, tpl string, f interface{})
- func (c *Context) Require(name string)
- func (c *Context) RequireAutosize()
- func (c *Context) RequireBasicAuth(username, password string)
- func (c *Context) RequireDropzone()
- func (c *Context) RequireHighlightJS()
- func (c *Context) RequireSimpleMDE()
- func (c *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{})
- func (c *Context) ServerError(title string, err error)
- func (c *Context) SubURLRedirect(location string, status ...int)
- func (c *Context) Success(name string)
- func (c *Context) Title(locale string)
- func (c *Context) UserID() int64
- type Organization
- type ParamsUser
- type PullRequest
- type Repository
- func (r *Repository) CanEnableEditor() bool
- func (r *Repository) GetEditorconfig() (*editorconfig.Editorconfig, error)
- func (r *Repository) HasAccess() bool
- func (r *Repository) IsAdmin() bool
- func (r *Repository) IsOwner() bool
- func (r *Repository) IsWriter() bool
- func (r *Repository) PullRequestURL(baseBranch, headBranch string) string
- type ToggleOptions
Constants ¶
const DOC_URL = "https://github.com/gogs/docs-api"
FIXME: move to github.com/gogs/go-gogs-client
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 InjectParamsUser ¶ added in v0.11.79
func InjectParamsUser() macaron.Handler
InjectParamsUser returns a handler that retrieves target user based on URL parameter ':username', and injects it as *ParamsUser.
func OrgAssignment ¶
func OrgAssignment(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 Toggle ¶
func Toggle(options *ToggleOptions) macaron.Handler
Types ¶
type APIContext ¶
type APIContext struct { *Context // TODO: Reduce to only needed fields instead of full shadow // Base URL for the version of API endpoints, e.g. https://try.gogs.io/api/v1 BaseURL string Org *APIOrganization }
func (*APIContext) Error ¶
func (c *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) NoContent ¶ added in v0.11.79
func (c *APIContext) NoContent()
NoContent renders the 204 response.
func (*APIContext) NotFound ¶ added in v0.11.79
func (c *APIContext) NotFound()
NotFound renders the 404 response.
func (*APIContext) NotFoundOrServerError ¶ added in v0.11.79
func (c *APIContext) NotFoundOrServerError(title string, errck func(error) bool, err error)
NotFoundOrServerError 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.
func (*APIContext) ServerError ¶ added in v0.11.79
func (c *APIContext) ServerError(title string, err error)
ServerError renders the 500 response.
func (*APIContext) SetLinkHeader ¶
func (c *APIContext) SetLinkHeader(total, pageSize int)
SetLinkHeader sets pagination link header by given total number and page size.
type Context ¶
type Context struct { *macaron.Context Cache cache.Cache Flash *session.Flash Session session.Store Link string // Current request URL User *models.User IsLogged bool IsBasicAuth bool IsTokenAuth bool Repo *Repository Org *Organization // contains filtered or unexported fields }
Context represents context of a request.
func (*Context) HandleText ¶
func (*Context) HasApiError ¶
HasError returns true if error occurs in form validation.
func (*Context) JSONSuccess ¶ added in v0.11.19
func (c *Context) JSONSuccess(data interface{})
JSONSuccess responses JSON with status http.StatusOK.
func (*Context) NotFoundOrServerError ¶
NotFoundOrServerError 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.
func (*Context) RawRedirect ¶ added in v0.11.79
RawRedirect simply calls underlying Redirect method with no escape.
func (*Context) Redirect ¶ added in v0.11.79
Redirect responses redirection wtih given location and status. It escapes special characters in the location string.
func (*Context) RenderWithErr ¶
RenderWithErr used for page has form validation but need to prompt error to users.
func (*Context) RequireAutosize ¶ added in v0.11.66
func (c *Context) RequireAutosize()
func (*Context) RequireBasicAuth ¶ added in v0.11.66
RequireBasicAuth verifies HTTP Basic Authentication header with given credentials
func (*Context) RequireDropzone ¶ added in v0.11.66
func (c *Context) RequireDropzone()
func (*Context) RequireHighlightJS ¶ added in v0.11.19
func (c *Context) RequireHighlightJS()
func (*Context) RequireSimpleMDE ¶ added in v0.11.19
func (c *Context) RequireSimpleMDE()
func (*Context) ServeContent ¶
func (c *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{})
func (*Context) ServerError ¶
ServerError renders the 500 page.
func (*Context) SubURLRedirect ¶ added in v0.11.19
SubURLRedirect responses redirection wtih given location and status. It prepends setting.AppSubURL to the location string.
type Organization ¶
type ParamsUser ¶ added in v0.11.79
ParamsUser is the wrapper type of the target user defined by URL parameter, namely ':username'.
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 TreePath string CommitID string RepoLink string CloneLink models.CloneLink CommitsCount int64 Mirror *models.Mirror PullRequest *PullRequest }
func (*Repository) CanEnableEditor ¶
func (r *Repository) CanEnableEditor() bool
CanEnableEditor returns true if repository is editable and user has proper access level.
func (*Repository) GetEditorconfig ¶
func (r *Repository) GetEditorconfig() (*editorconfig.Editorconfig, error)
GetEditorconfig returns the .editorconfig definition if found in the HEAD of the default repo branch.
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.
func (*Repository) PullRequestURL ¶
func (r *Repository) PullRequestURL(baseBranch, headBranch string) string
PullRequestURL returns URL for composing a pull request. This function does not check if the repository can actually compose a pull request.