36 lines
802 B
Go
36 lines
802 B
Go
package misc
|
|
|
|
import (
|
|
"code.gitea.io/gitea/modules/git"
|
|
Result "code.gitea.io/gitea/routers/entity"
|
|
"code.gitea.io/gitea/services/context"
|
|
)
|
|
|
|
// ObjectFormatType 定义返回API格式
|
|
type ObjectFormatType struct {
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// ListObjectFormats 返回 Object Formats 列表
|
|
func ListObjectFormats(ctx *context.APIContext) {
|
|
|
|
objectFormatList := git.DefaultFeatures().SupportedObjectFormats
|
|
|
|
var objectFormatNameList []ObjectFormatType
|
|
for _, format := range objectFormatList {
|
|
objectFormatNameList = append(objectFormatNameList,
|
|
ObjectFormatType{
|
|
Name: format.Name(),
|
|
},
|
|
)
|
|
}
|
|
|
|
resp := Result.ResultType{
|
|
Code: Result.RespSuccess.Code,
|
|
Msg: Result.RespSuccess.Msg,
|
|
Data: objectFormatNameList,
|
|
}
|
|
resp.RespondJson2HttpResponseWriter(ctx.Resp)
|
|
return
|
|
}
|