Documentation ¶
Index ¶
- Constants
- Variables
- func APIContexter() func(http.Handler) http.Handler
- func AccessLogger() func(http.Handler) http.Handler
- func AesDecrypt(key, text []byte) ([]byte, error)
- func AesEncrypt(key, text []byte) ([]byte, error)
- func ComposeGoGetImport(owner, repo string) string
- func Contexter() func(next http.Handler) http.Handler
- func DecryptSecret(key string, cipherhex string) (string, error)
- func EarlyResponseForGoGetMeta(ctx *Context)
- func EncryptSecret(key string, str string) (string, error)
- func GenerateToken(key, userID, actionID string) string
- func GetImageCaptcha() *captcha.Captcha
- func GitHookService() func(ctx *Context)
- func HandleOrgAssignment(ctx *Context, args ...bool)
- func NewSecret() (string, error)
- func NewSecretWithLength(length int64) (string, error)
- func OrgAssignment(args ...bool) func(ctx *Context)
- func PrivateContexter() func(http.Handler) http.Handler
- func RedirectToRepo(ctx *Context, redirectRepoID int64)
- func RedirectToUser(ctx *Context, userName string, redirectUserID int64)
- func ReferencesGitRepo(allowEmpty bool) func(http.Handler) http.Handler
- func RepoAssignment() func(http.Handler) http.Handler
- func RepoIDAssignment() func(ctx *Context)
- func RepoMustNotBeArchived() func(ctx *Context)
- func RepoRef() func(http.Handler) http.Handler
- func RepoRefByType(refType RepoRefType) func(http.Handler) http.Handler
- func RepoRefForAPI(next http.Handler) http.Handler
- func RequireRepoAdmin() func(ctx *Context)
- func RequireRepoReader(unitType models.UnitType) func(ctx *Context)
- func RequireRepoReaderOr(unitTypes ...models.UnitType) func(ctx *Context)
- func RequireRepoWriter(unitType models.UnitType) func(ctx *Context)
- func RequireRepoWriterOr(unitTypes ...models.UnitType) func(ctx *Context)
- func RetrieveBaseRepo(ctx *Context, repo *models.Repository)
- func RetrieveTemplateRepo(ctx *Context, repo *models.Repository)
- func SignedUserName(req *http.Request) string
- func Toggle(options *ToggleOptions) func(ctx *Context)
- func ToggleAPI(options *ToggleOptions) func(ctx *APIContext)
- func UnitTypes() func(ctx *Context)
- func ValidToken(token, key, userID, actionID string) bool
- func Validate(ctx *Context, x CSRF)
- func WithAPIContext(req *http.Request, ctx *APIContext) *http.Request
- func WithContext(req *http.Request, ctx *Context) *http.Request
- func WithPrivateContext(req *http.Request, ctx *PrivateContext) *http.Request
- type APIConflict
- type APIContext
- func (ctx *APIContext) CheckForOTP()
- func (ctx *APIContext) Error(status int, title string, obj interface{})
- func (ctx *APIContext) InternalServerError(err error)
- func (ctx *APIContext) NotFound(objs ...interface{})
- func (ctx *APIContext) RequireCSRF()
- func (ctx *APIContext) ServerError(title string, err error)
- func (ctx *APIContext) SetLinkHeader(total, pageSize int)
- type APIEmpty
- type APIError
- type APIForbiddenError
- type APIInvalidTopicsError
- type APINotFound
- type APIOrganization
- type APIRedirect
- type APIString
- type APIValidationError
- type CSRF
- type CanCommitToBranchResults
- type Context
- func (ctx *Context) CookieDecrypt(secret, val string) (string, bool)
- func (ctx *Context) CookieEncrypt(secret, value string) string
- func (ctx *Context) DeleteCookie(name string)
- func (ctx *Context) Error(status int, contents ...string)
- func (ctx *Context) GetCookie(name string) string
- func (ctx *Context) GetCookieFloat64(name string) float64
- func (ctx *Context) GetCookieInt(name string) int
- func (ctx *Context) GetCookieInt64(name string) int64
- func (ctx *Context) GetData() map[string]interface{}
- func (ctx *Context) GetErrMsg() string
- func (ctx *Context) GetSuperSecureCookie(secret, name string) (string, bool)
- func (ctx *Context) HTML(status int, name base.TplName)
- func (ctx *Context) HTMLString(name string, data interface{}) (string, error)
- func (ctx *Context) HandleText(status int, title string)
- func (ctx *Context) HasAPIError() bool
- func (ctx *Context) HasError() bool
- func (ctx *Context) HasValue(name string) bool
- func (ctx *Context) Header() http.Header
- func (ctx *Context) IsUserRepoAdmin() bool
- func (ctx *Context) IsUserRepoOwner() bool
- func (ctx *Context) IsUserRepoReaderAny() bool
- func (ctx *Context) IsUserRepoReaderSpecific(unitType models.UnitType) bool
- func (ctx *Context) IsUserRepoWriter(unitTypes []models.UnitType) bool
- func (ctx *Context) IsUserSiteAdmin() bool
- func (ctx *Context) IssueTemplatesFromDefaultBranch() []api.IssueTemplate
- func (ctx *Context) JSON(status int, content interface{})
- func (ctx *Context) NotFound(title string, err error)
- func (ctx *Context) NotFoundOrServerError(title string, errck func(error) bool, err error)
- func (ctx *Context) Params(p string) string
- func (ctx *Context) ParamsInt64(p string) int64
- func (ctx *Context) PlainText(status int, bs []byte)
- func (ctx *Context) Query(key string, defaults ...string) string
- func (ctx *Context) QueryBool(key string, defaults ...bool) bool
- func (ctx *Context) QueryInt(key string, defaults ...int) int
- func (ctx *Context) QueryInt64(key string, defaults ...int64) int64
- func (ctx *Context) QueryStrings(key string, defaults ...[]string) []string
- func (ctx *Context) QueryTrim(key string, defaults ...string) string
- func (ctx *Context) Redirect(location string, status ...int)
- func (ctx *Context) RedirectToFirst(location ...string)
- func (ctx *Context) RemoteAddr() string
- func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form interface{})
- func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{})
- func (ctx *Context) ServeFile(file string, names ...string)
- func (ctx *Context) ServerError(title string, err error)
- func (ctx *Context) SetCookie(name, value string, expiry int)
- func (ctx *Context) SetParams(k, v string)
- func (ctx *Context) SetSuperSecureCookie(secret, name, value string, expiry int)
- func (ctx *Context) Status(status int)
- func (ctx *Context) Write(bs []byte) (int, error)
- func (ctx *Context) Written() bool
- type CsrfOptions
- type Forms
- func (f *Forms) Bool(key string) (bool, error)
- func (f *Forms) Escape(key string) (string, error)
- func (f *Forms) Float32(key string) (float32, error)
- func (f *Forms) Float64(key string) (float64, error)
- func (f *Forms) Int(key string) (int, error)
- func (f *Forms) Int32(key string) (int32, error)
- func (f *Forms) Int64(key string) (int64, error)
- func (f *Forms) MustBool(key string, defaults ...bool) bool
- func (f *Forms) MustEscape(key string, defaults ...string) string
- func (f *Forms) MustFloat32(key string, defaults ...float32) float32
- func (f *Forms) MustFloat64(key string, defaults ...float64) float64
- func (f *Forms) MustInt(key string, defaults ...int) int
- func (f *Forms) MustInt32(key string, defaults ...int32) int32
- func (f *Forms) MustInt64(key string, defaults ...int64) int64
- func (f *Forms) MustString(key string, defaults ...string) string
- func (f *Forms) MustStrings(key string, defaults ...[]string) []string
- func (f *Forms) MustTrimmed(key string, defaults ...string) string
- func (f *Forms) MustUint(key string, defaults ...uint) uint
- func (f *Forms) MustUint32(key string, defaults ...uint32) uint32
- func (f *Forms) MustUint64(key string, defaults ...uint64) uint64
- func (f *Forms) String(key string) (string, error)
- func (f *Forms) Strings(key string) ([]string, error)
- func (f *Forms) Trimmed(key string) (string, error)
- func (f *Forms) Uint(key string) (uint, error)
- func (f *Forms) Uint32(key string) (uint32, error)
- func (f *Forms) Uint64(key string) (uint64, error)
- func (f *Forms) Values() url.Values
- type Handler
- type Organization
- type Pagination
- type PrivateContext
- type PullRequest
- type Render
- type RepoRefType
- type Repository
- func (r *Repository) BranchNameSubURL() string
- func (r *Repository) CanCommitToBranch(doer *models.User) (CanCommitToBranchResults, error)
- func (r *Repository) CanCreateBranch() bool
- func (r *Repository) CanCreateIssueDependencies(user *models.User, isPull bool) bool
- func (r *Repository) CanEnableEditor() bool
- func (r *Repository) CanUseTimetracker(issue *models.Issue, user *models.User) bool
- func (r *Repository) FileExists(path string, branch string) (bool, error)
- func (r *Repository) GetCommitGraphsCount(hidePRRefs bool, branches []string, files []string) (int64, error)
- func (r *Repository) GetCommitsCount() (int64, error)
- func (r *Repository) GetEditorconfig() (*editorconfig.Editorconfig, error)
- type Response
- type ResponseWriter
- type ToggleOptions
Constants ¶
const Timeout = 24 * time.Hour
Timeout represents the duration that XSRF tokens are valid. It is exported so clients may set cookie timeouts that match generated tokens.
Variables ¶
var IssueTemplateDirCandidates = []string{
"ISSUE_TEMPLATE",
"issue_template",
".gitea/ISSUE_TEMPLATE",
".gitea/issue_template",
".github/ISSUE_TEMPLATE",
".github/issue_template",
".gitlab/ISSUE_TEMPLATE",
".gitlab/issue_template",
}
IssueTemplateDirCandidates issue templates directory
Functions ¶
func APIContexter ¶
APIContexter returns apicontext as middleware
func AccessLogger ¶
AccessLogger returns a middleware to log access logger
func AesDecrypt ¶
AesDecrypt decrypts text and given key with AES.
func AesEncrypt ¶
AesEncrypt encrypts text and given key with AES.
func ComposeGoGetImport ¶ added in v1.2.0
ComposeGoGetImport returns go-get-import meta content.
func DecryptSecret ¶
DecryptSecret decrypts a previously encrypted hex string
func EarlyResponseForGoGetMeta ¶ added in v1.2.0
func EarlyResponseForGoGetMeta(ctx *Context)
EarlyResponseForGoGetMeta 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.
func EncryptSecret ¶
EncryptSecret encrypts a string with given key into a hex string
func GenerateToken ¶
GenerateToken returns a URL-safe secure XSRF token that expires in 24 hours.
key is a secret key for your application. userID is a unique identifier for the user. actionID is the action the user is taking (e.g. POSTing to a particular path).
func GetImageCaptcha ¶
GetImageCaptcha returns global image captcha
func GitHookService ¶
func GitHookService() func(ctx *Context)
GitHookService checks if repository Git hooks service has been enabled.
func HandleOrgAssignment ¶
HandleOrgAssignment handles organization assignment
func NewSecretWithLength ¶
NewSecretWithLength creates a new secret for a given length
func OrgAssignment ¶
OrgAssignment returns a middleware to handle organization assignment
func PrivateContexter ¶
PrivateContexter returns apicontext as middleware
func RedirectToRepo ¶ added in v1.1.0
RedirectToRepo redirect to a differently-named repository
func RedirectToUser ¶
RedirectToUser redirect to a differently-named user
func ReferencesGitRepo ¶ added in v1.0.0
ReferencesGitRepo injects the GitRepo into the Context
func RepoAssignment ¶
RepoAssignment returns a middleware to handle repository assignment
func RepoIDAssignment ¶ added in v1.2.0
func RepoIDAssignment() func(ctx *Context)
RepoIDAssignment returns a handler which assigns the repo to the context.
func RepoMustNotBeArchived ¶ added in v1.8.0
func RepoMustNotBeArchived() func(ctx *Context)
RepoMustNotBeArchived checks if a repo is archived
func RepoRefByType ¶ added in v1.3.0
func RepoRefByType(refType RepoRefType) func(http.Handler) http.Handler
RepoRefByType handles repository reference name for a specific type of repository reference
func RepoRefForAPI ¶
RepoRefForAPI handles repository reference names when the ref name is not explicitly given
func RequireRepoAdmin ¶
func RequireRepoAdmin() func(ctx *Context)
RequireRepoAdmin returns a middleware for requiring repository admin permission
func RequireRepoReader ¶ added in v1.7.0
RequireRepoReader returns a middleware for requiring repository read to the specify unitType
func RequireRepoReaderOr ¶ added in v1.7.0
RequireRepoReaderOr returns a middleware for requiring repository write to one of the unit permission
func RequireRepoWriter ¶
RequireRepoWriter returns a middleware for requiring repository write to the specify unitType
func RequireRepoWriterOr ¶ added in v1.7.0
RequireRepoWriterOr returns a middleware for requiring repository write to one of the unit permission
func RetrieveBaseRepo ¶
func RetrieveBaseRepo(ctx *Context, repo *models.Repository)
RetrieveBaseRepo retrieves base repository
func RetrieveTemplateRepo ¶
func RetrieveTemplateRepo(ctx *Context, repo *models.Repository)
RetrieveTemplateRepo retrieves template repository used to generate this repository
func SignedUserName ¶
SignedUserName returns signed user's name via context
func Toggle ¶
func Toggle(options *ToggleOptions) func(ctx *Context)
Toggle returns toggle options as middleware
func ToggleAPI ¶
func ToggleAPI(options *ToggleOptions) func(ctx *APIContext)
ToggleAPI returns toggle options as middleware
func UnitTypes ¶ added in v1.1.0
func UnitTypes() func(ctx *Context)
UnitTypes returns a middleware to set unit types to context variables.
func ValidToken ¶
ValidToken returns true if token is a valid, unexpired token returned by Generate.
func Validate ¶
Validate should be used as a per route middleware. It attempts to get a token from a "X-CSRFToken" HTTP header and then a "_csrf" form value. If one of these is found, the token will be validated using ValidToken. If this validation fails, custom Error is sent in the reply. If neither a header or form value is found, http.StatusBadRequest is sent.
func WithAPIContext ¶
func WithAPIContext(req *http.Request, ctx *APIContext) *http.Request
WithAPIContext set up api context in request
func WithContext ¶
WithContext set up install context in request
func WithPrivateContext ¶
func WithPrivateContext(req *http.Request, ctx *PrivateContext) *http.Request
WithPrivateContext set up private context in request
Types ¶
type APIConflict ¶
type APIConflict struct{}
APIConflict is a conflict empty response swagger:response conflict
type APIContext ¶
type APIContext struct { *Context Org *APIOrganization }
APIContext is a specific context for API service
func GetAPIContext ¶
func GetAPIContext(req *http.Request) *APIContext
GetAPIContext returns a context for API routes
func (*APIContext) CheckForOTP ¶ added in v1.8.0
func (ctx *APIContext) CheckForOTP()
CheckForOTP validates OTP
func (*APIContext) Error ¶
func (ctx *APIContext) Error(status int, title string, obj interface{})
Error responds with an error message to client with given obj as the message. If status is 500, also it prints error to log.
func (*APIContext) InternalServerError ¶
func (ctx *APIContext) InternalServerError(err error)
InternalServerError responds with an error message to the client with the error as a message and the file and line of the caller.
func (*APIContext) NotFound ¶
func (ctx *APIContext) NotFound(objs ...interface{})
NotFound handles 404s for APIContext String will replace message, errors will be added to a slice
func (*APIContext) RequireCSRF ¶ added in v1.6.0
func (ctx *APIContext) RequireCSRF()
RequireCSRF requires a validated a CSRF token
func (*APIContext) ServerError ¶
func (ctx *APIContext) ServerError(title string, err error)
ServerError responds with error message, status is 500
func (*APIContext) SetLinkHeader ¶
func (ctx *APIContext) SetLinkHeader(total, pageSize int)
SetLinkHeader sets pagination link header by given total number and page size.
type APIEmpty ¶ added in v1.2.0
type APIEmpty struct{}
APIEmpty is an empty response swagger:response empty
type APIForbiddenError ¶ added in v1.2.0
type APIForbiddenError struct {
APIError
}
APIForbiddenError is a forbidden error response swagger:response forbidden
type APIInvalidTopicsError ¶
type APIInvalidTopicsError struct { Topics []string `json:"invalidTopics"` Message string `json:"message"` }
APIInvalidTopicsError is error format response to invalid topics swagger:response invalidTopicsError
type APINotFound ¶ added in v1.2.0
type APINotFound struct{}
APINotFound is a not found empty response swagger:response notFound
type APIOrganization ¶
APIOrganization contains organization and team
type APIRedirect ¶ added in v1.2.0
type APIRedirect struct{}
APIRedirect is a redirect response swagger:response redirect
type APIValidationError ¶ added in v1.2.0
APIValidationError is error format response related to input validation swagger:response validationError
type CSRF ¶
type CSRF interface { // Return HTTP header to search for token. GetHeaderName() string // Return form value to search for token. GetFormName() string // Return cookie name to search for token. GetCookieName() string // Return cookie path GetCookiePath() string // Return the flag value used for the csrf token. GetCookieHTTPOnly() bool // Return cookie domain GetCookieDomain() string // Return the token. GetToken() string // Validate by token. ValidToken(t string) bool // Error replies to the request with a custom function when ValidToken fails. Error(w http.ResponseWriter) }
CSRF represents a CSRF service and is used to get the current token and validate a suspect token.
func Csrfer ¶
func Csrfer(opt CsrfOptions, ctx *Context) CSRF
Csrfer maps CSRF to each request. If this request is a Get request, it will generate a new token. Additionally, depending on options set, generated tokens will be sent via Header and/or Cookie.
type CanCommitToBranchResults ¶
type CanCommitToBranchResults struct { CanCommitToBranch bool EditorEnabled bool UserCanPush bool RequireSigned bool WillSign bool SigningKey string WontSignReason string }
CanCommitToBranchResults represents the results of CanCommitToBranch
type Context ¶
type Context struct { Resp ResponseWriter Req *http.Request Data map[string]interface{} Render Render translation.Locale Cache cache.Cache Flash *middleware.Flash Session session.Store Link string // current request URL EscapedLink string User *models.User IsSigned bool IsBasicAuth bool Repo *Repository Org *Organization // contains filtered or unexported fields }
Context represents context of a request.
func GetContext ¶
GetContext retrieves install context from request
func (*Context) CookieDecrypt ¶
CookieDecrypt returns given value from with secret string.
func (*Context) CookieEncrypt ¶
CookieEncrypt encrypts a given value using the provided secret
func (*Context) DeleteCookie ¶
DeleteCookie convenience function to delete most cookies consistently CSRF and a few others are the exception here
func (*Context) GetCookieFloat64 ¶
GetCookieFloat64 returns cookie result in float64 type.
func (*Context) GetCookieInt ¶
GetCookieInt returns cookie result in int type.
func (*Context) GetCookieInt64 ¶
GetCookieInt64 returns cookie result in int64 type.
func (*Context) GetSuperSecureCookie ¶
GetSuperSecureCookie returns given cookie value from request header with secret string.
func (*Context) HTMLString ¶
HTMLString render content to a string but not http.ResponseWriter
func (*Context) HandleText ¶
HandleText handles HTTP status code
func (*Context) HasAPIError ¶ added in v1.0.0
HasAPIError returns true if error occurs in form validation.
func (*Context) IsUserRepoAdmin ¶
IsUserRepoAdmin returns true if current user is admin in current repo
func (*Context) IsUserRepoOwner ¶
IsUserRepoOwner returns true if current user owns current repo
func (*Context) IsUserRepoReaderAny ¶
IsUserRepoReaderAny returns true if current user can read any part of current repo
func (*Context) IsUserRepoReaderSpecific ¶
IsUserRepoReaderSpecific returns true if current user can read current repo's specific part
func (*Context) IsUserRepoWriter ¶
IsUserRepoWriter returns true if current user has write privilege in current repo
func (*Context) IsUserSiteAdmin ¶
IsUserSiteAdmin returns true if current user is a site admin
func (*Context) IssueTemplatesFromDefaultBranch ¶
func (ctx *Context) IssueTemplatesFromDefaultBranch() []api.IssueTemplate
IssueTemplatesFromDefaultBranch checks for issue templates in the repo's default branch
func (*Context) NotFound ¶ added in v1.4.0
NotFound displays a 404 (Not Found) page and prints the given error, if any.
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) ParamsInt64 ¶
ParamsInt64 returns the param on route as int64
func (*Context) QueryInt64 ¶
QueryInt64 returns request form as int64 with default
func (*Context) QueryStrings ¶
QueryStrings returns request form as strings with default
func (*Context) QueryTrim ¶
QueryTrim returns request form as string with default and trimmed spaces
func (*Context) RedirectToFirst ¶ added in v1.4.0
RedirectToFirst redirects to first not empty URL
func (*Context) RemoteAddr ¶
RemoteAddr returns the client machie ip address
func (*Context) RenderWithErr ¶
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{})
ServeContent serves content to http request
func (*Context) ServerError ¶ added in v1.4.0
ServerError displays a 500 (Internal Server Error) page and prints the given error, if any.
func (*Context) SetCookie ¶
SetCookie convenience function to set most cookies consistently CSRF and a few others are the exception here
func (*Context) SetSuperSecureCookie ¶
SetSuperSecureCookie sets given cookie value to response header with secret string.
type CsrfOptions ¶
type CsrfOptions struct { // The global secret value used to generate Tokens. Secret string // HTTP header used to set and get token. Header string // Form value used to set and get token. Form string // Cookie value used to set and get token. Cookie string // Cookie domain. CookieDomain string // Cookie path. CookiePath string CookieHTTPOnly bool // SameSite set the cookie SameSite type SameSite http.SameSite // Key used for getting the unique ID per user. SessionKey string // If true, send token via X-CSRFToken header. SetHeader bool // If true, send token via _csrf cookie. SetCookie bool // Set the Secure flag to true on the cookie. Secure bool // Disallow Origin appear in request header. Origin bool // The function called when Validate fails. ErrorFunc func(w http.ResponseWriter) // Cookie life time. Default is 0 CookieLifeTime int // contains filtered or unexported fields }
CsrfOptions maintains options to manage behavior of Generate.
type Forms ¶
Forms a new enhancement of http.Request
func (*Forms) MustEscape ¶
MustEscape returns request form as escaped string with default
func (*Forms) MustFloat32 ¶
MustFloat32 returns request form as float32 with default
func (*Forms) MustFloat64 ¶
MustFloat64 returns request form as float64 with default
func (*Forms) MustString ¶
MustString returns request form as string with default
func (*Forms) MustStrings ¶
MustStrings returns request form as strings with default
func (*Forms) MustTrimmed ¶
MustTrimmed returns request form as string with default
func (*Forms) MustUint32 ¶
MustUint32 returns request form as uint32 with default
func (*Forms) MustUint64 ¶
MustUint64 returns request form as uint64 with default
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 CanCreateOrgRepo bool Team *models.Team }
Organization contains organization context
type Pagination ¶
Pagination provides a pagination via Paginater and additional configurations for the link params used in rendering
func NewPagination ¶
func NewPagination(total int, page int, issueNum int, numPages int) *Pagination
NewPagination creates a new instance of the Pagination struct
func (*Pagination) AddParam ¶
func (p *Pagination) AddParam(ctx *Context, paramKey string, ctxKey string)
AddParam adds a value from context identified by ctxKey as link param under a given paramKey
func (*Pagination) AddParamString ¶
func (p *Pagination) AddParamString(key string, value string)
AddParamString adds a string parameter directly
func (*Pagination) GetParams ¶
func (p *Pagination) GetParams() template.URL
GetParams returns the configured URL params
func (*Pagination) SetDefaultParams ¶
func (p *Pagination) SetDefaultParams(ctx *Context)
SetDefaultParams sets common pagination params that are often used
type PrivateContext ¶
type PrivateContext struct {
*Context
}
PrivateContext represents a context for private routes
func GetPrivateContext ¶
func GetPrivateContext(req *http.Request) *PrivateContext
GetPrivateContext returns a context for Private routes
type PullRequest ¶
type PullRequest struct { BaseRepo *models.Repository Allowed bool SameRepo bool HeadInfo string // [<user>:]<branch> }
PullRequest contains informations to make a pull request
type Render ¶
type Render interface { TemplateLookup(tmpl string) *template.Template HTML(w io.Writer, status int, name string, binding interface{}, htmlOpt ...render.HTMLOptions) error }
Render represents a template render
type RepoRefType ¶ added in v1.3.0
type RepoRefType int
RepoRefType type of repo reference
const ( // RepoRefLegacy unknown type, make educated guess and redirect. // for backward compatibility with previous URL scheme RepoRefLegacy RepoRefType = iota // RepoRefAny is for usage where educated guess is needed // but redirect can not be made RepoRefAny // RepoRefBranch branch RepoRefBranch // RepoRefTag tag RepoRefTag // RepoRefCommit commit RepoRefCommit // RepoRefBlob blob RepoRefBlob )
func (RepoRefType) RefTypeIncludesBranches ¶
func (rt RepoRefType) RefTypeIncludesBranches() bool
RefTypeIncludesBranches returns true if ref type can be a branch
func (RepoRefType) RefTypeIncludesTags ¶
func (rt RepoRefType) RefTypeIncludesTags() bool
RefTypeIncludesTags returns true if ref type can be a tag
type Repository ¶
type Repository struct { models.Permission 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 }
Repository contains information to operate a repository
func (*Repository) BranchNameSubURL ¶ added in v1.3.0
func (r *Repository) BranchNameSubURL() string
BranchNameSubURL sub-URL for the BranchName field
func (*Repository) CanCommitToBranch ¶ added in v1.2.0
func (r *Repository) CanCommitToBranch(doer *models.User) (CanCommitToBranchResults, error)
CanCommitToBranch returns true if repository is editable and user has proper access level
and branch is not protected for push
func (*Repository) CanCreateBranch ¶ added in v1.3.0
func (r *Repository) CanCreateBranch() bool
CanCreateBranch returns true if repository is editable and user has proper access level.
func (*Repository) CanCreateIssueDependencies ¶ added in v1.6.0
func (r *Repository) CanCreateIssueDependencies(user *models.User, isPull bool) bool
CanCreateIssueDependencies returns whether or not a user can create dependencies.
func (*Repository) CanEnableEditor ¶
func (r *Repository) CanEnableEditor() bool
CanEnableEditor returns true if repository is editable and user has proper access level.
func (*Repository) CanUseTimetracker ¶ added in v1.3.0
CanUseTimetracker returns whether or not a user can use the timetracker.
func (*Repository) FileExists ¶
func (r *Repository) FileExists(path string, branch string) (bool, error)
FileExists returns true if a file exists in the given repo branch
func (*Repository) GetCommitGraphsCount ¶
func (r *Repository) GetCommitGraphsCount(hidePRRefs bool, branches []string, files []string) (int64, error)
GetCommitGraphsCount returns cached commit count for current view
func (*Repository) GetCommitsCount ¶ added in v1.3.0
func (r *Repository) GetCommitsCount() (int64, error)
GetCommitsCount returns cached commit count for current view
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.
type Response ¶
type Response struct { http.ResponseWriter // contains filtered or unexported fields }
Response represents a response
func NewResponse ¶
func NewResponse(resp http.ResponseWriter) *Response
NewResponse creates a response
func (*Response) Before ¶
func (r *Response) Before(f func(ResponseWriter))
Before allows for a function to be called before the ResponseWriter has been written to. This is useful for setting headers or any other operations that must happen before a response has been written.
func (*Response) WriteHeader ¶
WriteHeader write status code
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter Flush() Status() int Before(func(ResponseWriter)) Size() int }
ResponseWriter represents a response writer for HTTP