Versions in this module Expand all Collapse all v0 v0.19.4 May 24, 2023 Changes in this version + const CookieNameFlash + const CsrfTokenTimeout + var CsrfTokenRegenerationInterval = 10 * time.Minute + var WebContextKey = webContextKeyType + func APIContexter() func(http.Handler) http.Handler + func AccessLogger() func(http.Handler) http.Handler + func CanEnableEditor() func(ctx *Context) + func CheckRepoScopedToken(ctx *Context, repo *repo_model.Repository) + func ComposeGoGetImport(owner, repo string) string + func Contexter() func(next http.Handler) http.Handler + func EarlyResponseForGoGetMeta(ctx *Context) + func GenerateCsrfToken(key, userID, actionID string, now time.Time) string + func GetImageCaptcha() *captcha.Captcha + func GetOrganizationByParams(ctx *Context) + func GetQueryBeforeSince(ctx *Base) (before, since int64, err error) + func GitHookService() func(ctx *Context) + func HandleOrgAssignment(ctx *Context, args ...bool) + func OrgAssignment(args ...bool) func(ctx *Context) + func OverrideContext(ctx *PrivateContext) (cancel context.CancelFunc) + func PackageAssignment() func(ctx *Context) + func PackageAssignmentAPI() func(ctx *APIContext) + func PackageContexter() func(next http.Handler) http.Handler + func ParseCsrfToken(token string) (issueTime time.Time, ok bool) + func PrivateContexter() func(http.Handler) http.Handler + func RedirectToRepo(ctx *Base, redirectRepoID int64) + func RedirectToUser(ctx *Base, userName string, redirectUserID int64) + func ReferencesGitRepo(allowEmpty ...bool) func(ctx *APIContext) (cancel context.CancelFunc) + func RepoAssignment(ctx *Context) (cancel context.CancelFunc) + func RepoIDAssignment() func(ctx *Context) + func RepoMustNotBeArchived() func(ctx *Context) + func RepoRef() func(*Context) context.CancelFunc + func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context) context.CancelFunc + func RepoRefForAPI(next http.Handler) http.Handler + func RequireRepoAdmin() func(ctx *Context) + func RequireRepoReader(unitType unit.Type) func(ctx *Context) + func RequireRepoReaderOr(unitTypes ...unit.Type) func(ctx *Context) + func RequireRepoWriter(unitType unit.Type) func(ctx *Context) + func RequireRepoWriterOr(unitTypes ...unit.Type) func(ctx *Context) + func RetrieveBaseRepo(ctx *Context, repo *repo_model.Repository) + func RetrieveTemplateRepo(ctx *Context, repo *repo_model.Repository) + func SetCaptchaData(ctx *Context) + func UnitTypes() func(ctx *Context) + func ValidCsrfToken(token, key, userID, actionID string, now time.Time) bool + func VerifyCaptcha(ctx *Context, tpl base.TplName, form interface{}) + type APIConflict struct + type APIContext struct + Cache cache.Cache + ContextUser *user_model.User + Doer *user_model.User + IsBasicAuth bool + IsSigned bool + Org *APIOrganization + Package *Package + Repo *Repository + func GetAPIContext(req *http.Request) *APIContext + func (ctx *APIContext) CheckForOTP() + func (ctx *APIContext) Error(status int, title string, obj interface{}) + func (ctx *APIContext) GetErrMsg() string + func (ctx *APIContext) HasAPIError() bool + func (ctx *APIContext) InternalServerError(err error) + func (ctx *APIContext) IsUserRepoAdmin() bool + func (ctx *APIContext) IsUserRepoWriter(unitTypes []unit.Type) bool + func (ctx *APIContext) IsUserSiteAdmin() bool + func (ctx *APIContext) NotFound(objs ...interface{}) + func (ctx *APIContext) NotFoundOrServerError(logMsg string, errCheck func(error) bool, logErr error) + func (ctx *APIContext) ServerError(title string, err error) + func (ctx *APIContext) SetLinkHeader(total, pageSize int) + type APIEmpty struct + type APIError struct + Message string + URL string + type APIForbiddenError struct + type APIInvalidTopicsError struct + InvalidTopics []string + Message string + type APINotFound struct + type APIOrganization struct + Organization *organization.Organization + Team *organization.Team + type APIRedirect struct + type APIString string + type APIValidationError struct + Message string + URL string + type Base struct + Data middleware.ContextData + Locale translation.Locale + Req *http.Request + Resp ResponseWriter + func NewBaseContext(resp http.ResponseWriter, req *http.Request) (b *Base, closeFunc func()) + func (b *Base) AppendAccessControlExposeHeaders(names ...string) + func (b *Base) AppendContextValue(key, value any) any + func (b *Base) AppendContextValueFunc(key any, valueFn func() any) any + func (b *Base) Deadline() (deadline time.Time, ok bool) + func (b *Base) Done() <-chan struct{} + func (b *Base) Err() error + func (b *Base) Error(status int, contents ...string) + func (b *Base) FormBool(key string) bool + func (b *Base) FormInt(key string) int + func (b *Base) FormInt64(key string) int64 + func (b *Base) FormOptionalBool(key string) util.OptionalBool + func (b *Base) FormString(key string) string + func (b *Base) FormStrings(key string) []string + func (b *Base) FormTrim(key string) string + func (b *Base) GetData() middleware.ContextData + func (b *Base) JSON(status int, content interface{}) + func (b *Base) Params(p string) string + func (b *Base) ParamsInt64(p string) int64 + func (b *Base) PlainText(status int, text string) + func (b *Base) PlainTextBytes(status int, bs []byte) + func (b *Base) Redirect(location string, status ...int) + func (b *Base) RemoteAddr() string + func (b *Base) RespHeader() http.Header + func (b *Base) ServeContent(r io.ReadSeeker, opts *ServeHeaderOptions) + func (b *Base) SetFormString(key, value string) + func (b *Base) SetParams(k, v string) + func (b *Base) SetServeHeaders(opt *ServeHeaderOptions) + func (b *Base) SetTotalCountHeader(total int64) + func (b *Base) Status(status int) + func (b *Base) Tr(msg string, args ...any) string + func (b *Base) TrN(cnt any, key1, keyN string, args ...any) string + func (b *Base) Value(key any) any + func (b *Base) Write(bs []byte) (int, error) + func (b *Base) Written() bool + type CSRFProtector interface + DeleteCookie func(ctx *Context) + GetFormName func() string + GetHeaderName func() string + GetToken func() string + Validate func(ctx *Context) + func PrepareCSRFProtector(opt CsrfOptions, ctx *Context) CSRFProtector + type CanCommitToBranchResults struct + CanCommitToBranch bool + EditorEnabled bool + RequireSigned bool + SigningKey string + UserCanPush bool + WillSign bool + WontSignReason string + type Context struct + Cache cache.Cache + ContextUser *user_model.User + Csrf CSRFProtector + Doer *user_model.User + Flash *middleware.Flash + IsBasicAuth bool + IsSigned bool + Link string + Org *Organization + Package *Package + PageData map[string]any + Render Render + Repo *Repository + Session session.Store + func GetWebContext(req *http.Request) *Context + func (ctx *Context) CookieDecrypt(secret, val string) (string, bool) + func (ctx *Context) CookieEncrypt(secret, value string) string + func (ctx *Context) DeleteSiteCookie(name string) + func (ctx *Context) GetErrMsg() string + func (ctx *Context) GetSiteCookie(name string) string + func (ctx *Context) GetSuperSecureCookie(secret, name string) (string, bool) + func (ctx *Context) HTML(status int, name base.TplName) + func (ctx *Context) HasError() bool + func (ctx *Context) IsUserRepoAdmin() bool + func (ctx *Context) IsUserRepoWriter(unitTypes []unit.Type) bool + func (ctx *Context) IsUserSiteAdmin() bool + func (ctx *Context) NotFound(logMsg string, logErr error) + func (ctx *Context) NotFoundOrServerError(logMsg string, errCheck func(error) bool, logErr error) + func (ctx *Context) RedirectToFirst(location ...string) + func (ctx *Context) RenderToString(name base.TplName, data map[string]interface{}) (string, error) + func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form interface{}) + func (ctx *Context) ServerError(logMsg string, logErr error) + func (ctx *Context) SetSiteCookie(name, value string, maxAge int) + func (ctx *Context) SetSuperSecureCookie(secret, name, value string, maxAge int) + func (ctx *Context) TrHTMLEscapeArgs(msg string, args ...string) string + func (ctx *Context) UploadStream() (rd io.ReadCloser, needToClose bool, err error) + type CsrfOptions struct + Cookie string + CookieDomain string + CookieHTTPOnly bool + CookieLifeTime int + CookiePath string + Form string + Header string + Origin bool + SameSite http.SameSite + Secret string + Secure bool + SessionKey string + SetCookie bool + SetHeader bool + type Organization struct + CanCreateOrgRepo bool + IsMember bool + IsOwner bool + IsTeamAdmin bool + IsTeamMember bool + OrgLink string + Organization *organization.Organization + Team *organization.Team + Teams []*organization.Team + func (org *Organization) CanReadUnit(ctx *Context, unitType unit.Type) bool + func (org *Organization) CanWriteUnit(ctx *Context, unitType unit.Type) bool + type Package struct + AccessMode perm.AccessMode + Descriptor *packages_model.PackageDescriptor + Owner *user_model.User + type Pagination struct + Paginater *paginator.Paginator + func NewPagination(total, pagingNum, current, numPages int) *Pagination + func (p *Pagination) AddParam(ctx *Context, paramKey, ctxKey string) + func (p *Pagination) AddParamString(key, value string) + func (p *Pagination) GetParams() template.URL + func (p *Pagination) SetDefaultParams(ctx *Context) + type PrivateContext struct + Override context.Context + Repo *Repository + func GetPrivateContext(req *http.Request) *PrivateContext + func (ctx *PrivateContext) Deadline() (deadline time.Time, ok bool) + func (ctx *PrivateContext) Done() <-chan struct{} + func (ctx *PrivateContext) Err() error + type PullRequest struct + Allowed bool + BaseRepo *repo_model.Repository + HeadInfoSubURL string + SameRepo bool + type Render interface + HTML func(w io.Writer, status int, name string, data interface{}) error + TemplateLookup func(tmpl string) (templates.TemplateExecutor, error) + type RepoRefType int + const RepoRefAny + const RepoRefBlob + const RepoRefBranch + const RepoRefCommit + const RepoRefLegacy + const RepoRefTag + func (rt RepoRefType) RefTypeIncludesBranches() bool + func (rt RepoRefType) RefTypeIncludesTags() bool + type Repository struct + BranchName string + CloneLink repo_model.CloneLink + Commit *git.Commit + CommitID string + CommitsCount int64 + GitRepo *git.Repository + IsViewBranch bool + IsViewCommit bool + IsViewTag bool + IsWatching bool + Owner *user_model.User + PullRequest *PullRequest + RefName string + RepoLink string + Repository *repo_model.Repository + Tag *git.Tag + TagName string + TreePath string + func (r *Repository) BranchNameSubURL() string + func (r *Repository) CanCommitToBranch(ctx context.Context, doer *user_model.User) (CanCommitToBranchResults, error) + func (r *Repository) CanCreateBranch() bool + func (r *Repository) CanCreateIssueDependencies(user *user_model.User, isPull bool) bool + func (r *Repository) CanEnableEditor(user *user_model.User) bool + func (r *Repository) CanUseTimetracker(issue *issues_model.Issue, user *user_model.User) bool + func (r *Repository) CanWriteToBranch(user *user_model.User, branch string) bool + func (r *Repository) FileExists(path, branch string) (bool, error) + func (r *Repository) GetCommitGraphsCount(ctx context.Context, hidePRRefs bool, branches, files []string) (int64, error) + func (r *Repository) GetCommitsCount() (int64, error) + func (r *Repository) GetEditorconfig(optCommit ...*git.Commit) (cfg *editorconfig.Editorconfig, warning, err error) + type Response struct + func WrapResponseWriter(resp http.ResponseWriter) *Response + func (r *Response) Before(f func(ResponseWriter)) + func (r *Response) Flush() + func (r *Response) Size() int + func (r *Response) Status() int + func (r *Response) Write(bs []byte) (int, error) + func (r *Response) WriteHeader(statusCode int) + type ResponseWriter interface + Before func(func(ResponseWriter)) + Size func() int + Status func() int + type ServeHeaderOptions httplib.ServeHeaderOptions + type ValidateContext struct + func GetValidateContext(req *http.Request) (ctx *ValidateContext)