mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-10 05:24:18 +09:00
Enable [`forcetypeassert`](https://github.com/gostaticanalysis/forcetypeassert) linter to prevent unchecked type assertions. ~650 issues fixed, most fixes were clean, some use `setting.PanicInDevOrTesting`. The only behaviour changes are where code would previously send a 500 error or panic, a 4xx error is now emitted. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
// Copyright 2015 The Gogs Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package admin
|
|
|
|
import (
|
|
api "gitea.dev/modules/structs"
|
|
"gitea.dev/modules/web"
|
|
"gitea.dev/routers/api/v1/repo"
|
|
"gitea.dev/services/context"
|
|
)
|
|
|
|
// CreateRepo api for creating a repository
|
|
func CreateRepo(ctx *context.APIContext) {
|
|
// swagger:operation POST /admin/users/{username}/repos admin adminCreateRepo
|
|
// ---
|
|
// summary: Create a repository on behalf of a user
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: username
|
|
// in: path
|
|
// description: username of the user who will own the created repository
|
|
// type: string
|
|
// required: true
|
|
// - name: repository
|
|
// in: body
|
|
// required: true
|
|
// schema: { "$ref": "#/definitions/CreateRepoOption" }
|
|
// responses:
|
|
// "201":
|
|
// "$ref": "#/responses/Repository"
|
|
// "400":
|
|
// "$ref": "#/responses/error"
|
|
// "403":
|
|
// "$ref": "#/responses/forbidden"
|
|
// "404":
|
|
// "$ref": "#/responses/notFound"
|
|
// "409":
|
|
// "$ref": "#/responses/error"
|
|
// "422":
|
|
// "$ref": "#/responses/validationError"
|
|
|
|
form := web.GetForm[*api.CreateRepoOption](ctx)
|
|
|
|
repo.CreateUserRepo(ctx, ctx.ContextUser, *form)
|
|
}
|