mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
routers: able to migrate repo from local path
- modules/middleware/context.go: add HandleAPI method
This commit is contained in:
@@ -31,7 +31,7 @@ func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) bin
|
||||
}
|
||||
|
||||
type MigrateRepoForm struct {
|
||||
HttpsUrl string `form:"url" binding:"Required;Url"`
|
||||
CloneAddr string `binding:"Required"`
|
||||
AuthUserName string `form:"auth_username"`
|
||||
AuthPasswd string `form:"auth_password"`
|
||||
Uid int64 `form:"uid" binding:"Required"`
|
||||
|
@@ -130,6 +130,18 @@ func (ctx *Context) Handle(status int, title string, err error) {
|
||||
ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status)))
|
||||
}
|
||||
|
||||
func (ctx *Context) HandleAPI(status int, obj interface{}) {
|
||||
var message string
|
||||
if err, ok := obj.(error); ok {
|
||||
message = err.Error()
|
||||
} else {
|
||||
message = obj.(string)
|
||||
}
|
||||
ctx.JSON(status, map[string]string{
|
||||
"message": message,
|
||||
})
|
||||
}
|
||||
|
||||
func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) {
|
||||
modtime := time.Now()
|
||||
for _, p := range params {
|
||||
|
Reference in New Issue
Block a user