|
|
@ -27,6 +27,18 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
// HTTP implmentation git smart HTTP protocol
|
|
|
|
// HTTP implmentation git smart HTTP protocol
|
|
|
|
func HTTP(ctx *context.Context) { |
|
|
|
func HTTP(ctx *context.Context) { |
|
|
|
|
|
|
|
if len(setting.Repository.AccessControlAllowOrigin) > 0 { |
|
|
|
|
|
|
|
// Set CORS headers for browser-based git clients
|
|
|
|
|
|
|
|
ctx.Resp.Header().Set("Access-Control-Allow-Origin", setting.Repository.AccessControlAllowOrigin) |
|
|
|
|
|
|
|
ctx.Resp.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, User-Agent") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle preflight OPTIONS request
|
|
|
|
|
|
|
|
if ctx.Req.Method == "OPTIONS" { |
|
|
|
|
|
|
|
ctx.Status(http.StatusOK) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
username := ctx.Params(":username") |
|
|
|
username := ctx.Params(":username") |
|
|
|
reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git") |
|
|
|
reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git") |
|
|
|
|
|
|
|
|
|
|
|