(g *gin.RouterGroup)
| 12 | ) |
| 13 | |
| 14 | func S3(g *gin.RouterGroup) { |
| 15 | if !conf.Conf.S3.Enable { |
| 16 | g.Any("/*path", func(c *gin.Context) { |
| 17 | common.ErrorStrResp(c, "S3 server is not enabled", 403) |
| 18 | }) |
| 19 | return |
| 20 | } |
| 21 | if conf.Conf.S3.Port != -1 { |
| 22 | g.Any("/*path", func(c *gin.Context) { |
| 23 | common.ErrorStrResp(c, "S3 server bound to single port", 403) |
| 24 | }) |
| 25 | return |
| 26 | } |
| 27 | h, _ := s3.NewServer(context.Background()) |
| 28 | |
| 29 | g.Any("/*path", func(c *gin.Context) { |
| 30 | adjustedPath := strings.TrimPrefix(c.Request.URL.Path, path.Join(conf.URL.Path, "/s3")) |
| 31 | c.Request.URL.Path = adjustedPath |
| 32 | gin.WrapH(h)(c) |
| 33 | }) |
| 34 | } |
| 35 | |
| 36 | func S3Server(g *gin.RouterGroup) { |
| 37 | h, _ := s3.NewServer(context.Background()) |
no test coverage detected