mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 06:21:11 +00:00 
			
		
		
		
	- Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`. - Resolves forgejo/discussions#258 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7337 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
		
			
				
	
	
		
			25 lines
		
	
	
	
		
			658 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			658 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2023, 2024 The Forgejo Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package context
 | |
| 
 | |
| import (
 | |
| 	"net/http"
 | |
| 
 | |
| 	repo_model "forgejo.org/models/repo"
 | |
| )
 | |
| 
 | |
| // RepositoryIDAssignmentAPI returns a middleware to handle context-repo assignment for api routes
 | |
| func RepositoryIDAssignmentAPI() func(ctx *APIContext) {
 | |
| 	return func(ctx *APIContext) {
 | |
| 		repositoryID := ctx.ParamsInt64(":repository-id")
 | |
| 
 | |
| 		var err error
 | |
| 		repository := new(Repository)
 | |
| 		repository.Repository, err = repo_model.GetRepositoryByID(ctx, repositoryID)
 | |
| 		if err != nil {
 | |
| 			ctx.Error(http.StatusNotFound, "GetRepositoryByID", err)
 | |
| 		}
 | |
| 		ctx.Repo = repository
 | |
| 	}
 | |
| }
 |