mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Update docs and comments to remove macaron (#14491)
This commit is contained in:
		@@ -23,7 +23,7 @@ import (
 | 
			
		||||
	"gitea.com/go-chi/session"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// APIContext is a specific macaron context for API service
 | 
			
		||||
// APIContext is a specific context for API service
 | 
			
		||||
type APIContext struct {
 | 
			
		||||
	*Context
 | 
			
		||||
	Org *APIOrganization
 | 
			
		||||
@@ -217,7 +217,7 @@ func (ctx *APIContext) CheckForOTP() {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// APIContexter returns apicontext as macaron middleware
 | 
			
		||||
// APIContexter returns apicontext as middleware
 | 
			
		||||
func APIContexter() func(http.Handler) http.Handler {
 | 
			
		||||
	var csrfOpts = getCsrfOpts()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -170,7 +170,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// OrgAssignment returns a macaron middleware to handle organization assignment
 | 
			
		||||
// OrgAssignment returns a middleware to handle organization assignment
 | 
			
		||||
func OrgAssignment(args ...bool) func(ctx *Context) {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		HandleOrgAssignment(ctx, args...)
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ import (
 | 
			
		||||
	"code.gitea.io/gitea/modules/log"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// RequireRepoAdmin returns a macaron middleware for requiring repository admin permission
 | 
			
		||||
// RequireRepoAdmin returns a middleware for requiring repository admin permission
 | 
			
		||||
func RequireRepoAdmin() func(ctx *Context) {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		if !ctx.IsSigned || !ctx.Repo.IsAdmin() {
 | 
			
		||||
@@ -19,7 +19,7 @@ func RequireRepoAdmin() func(ctx *Context) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RequireRepoWriter returns a macaron middleware for requiring repository write to the specify unitType
 | 
			
		||||
// RequireRepoWriter returns a middleware for requiring repository write to the specify unitType
 | 
			
		||||
func RequireRepoWriter(unitType models.UnitType) func(ctx *Context) {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		if !ctx.Repo.CanWrite(unitType) {
 | 
			
		||||
@@ -29,7 +29,7 @@ func RequireRepoWriter(unitType models.UnitType) func(ctx *Context) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RequireRepoWriterOr returns a macaron middleware for requiring repository write to one of the unit permission
 | 
			
		||||
// RequireRepoWriterOr returns a middleware for requiring repository write to one of the unit permission
 | 
			
		||||
func RequireRepoWriterOr(unitTypes ...models.UnitType) func(ctx *Context) {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		for _, unitType := range unitTypes {
 | 
			
		||||
@@ -41,7 +41,7 @@ func RequireRepoWriterOr(unitTypes ...models.UnitType) func(ctx *Context) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RequireRepoReader returns a macaron middleware for requiring repository read to the specify unitType
 | 
			
		||||
// RequireRepoReader returns a middleware for requiring repository read to the specify unitType
 | 
			
		||||
func RequireRepoReader(unitType models.UnitType) func(ctx *Context) {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		if !ctx.Repo.CanRead(unitType) {
 | 
			
		||||
@@ -67,7 +67,7 @@ func RequireRepoReader(unitType models.UnitType) func(ctx *Context) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RequireRepoReaderOr returns a macaron middleware for requiring repository write to one of the unit permission
 | 
			
		||||
// RequireRepoReaderOr returns a middleware for requiring repository write to one of the unit permission
 | 
			
		||||
func RequireRepoReaderOr(unitTypes ...models.UnitType) func(ctx *Context) {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		for _, unitType := range unitTypes {
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ func GetPrivateContext(req *http.Request) *PrivateContext {
 | 
			
		||||
	return req.Context().Value(privateContextKey).(*PrivateContext)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PrivateContexter returns apicontext as macaron middleware
 | 
			
		||||
// PrivateContexter returns apicontext as middleware
 | 
			
		||||
func PrivateContexter() func(http.Handler) http.Handler {
 | 
			
		||||
	return func(next http.Handler) http.Handler {
 | 
			
		||||
		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
 | 
			
		||||
 
 | 
			
		||||
@@ -373,7 +373,7 @@ func repoAssignment(ctx *Context, repo *models.Repository) {
 | 
			
		||||
	ctx.Data["IsEmptyRepo"] = ctx.Repo.Repository.IsEmpty
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RepoIDAssignment returns a macaron handler which assigns the repo to the context.
 | 
			
		||||
// RepoIDAssignment returns a handler which assigns the repo to the context.
 | 
			
		||||
func RepoIDAssignment() func(ctx *Context) {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		repoID := ctx.ParamsInt64(":repoid")
 | 
			
		||||
@@ -393,7 +393,7 @@ func RepoIDAssignment() func(ctx *Context) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RepoAssignment returns a macaron to handle repository assignment
 | 
			
		||||
// RepoAssignment returns a middleware to handle repository assignment
 | 
			
		||||
func RepoAssignment() func(http.Handler) http.Handler {
 | 
			
		||||
	return func(next http.Handler) http.Handler {
 | 
			
		||||
		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
 | 
			
		||||
@@ -849,7 +849,7 @@ func GitHookService() func(ctx *Context) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UnitTypes returns a macaron middleware to set unit types to context variables.
 | 
			
		||||
// UnitTypes returns a middleware to set unit types to context variables.
 | 
			
		||||
func UnitTypes() func(ctx *Context) {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		ctx.Data["UnitTypeCode"] = models.UnitTypeCode
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user