diff --git a/s3event/event.go b/s3event/event.go index e172836..32c49f0 100644 --- a/s3event/event.go +++ b/s3event/event.go @@ -141,7 +141,12 @@ func InitEventSender(cfg *EventConfig) (S3EventSender, error) { func createEventSchema(ctx *fiber.Ctx, meta EventMeta, configId ConfigurationId) EventSchema { path := strings.Split(ctx.Path(), "/") - bucket, object := path[1], strings.Join(path[2:], "/") + + var bucket, object string + if len(path) > 1 { + bucket, object = path[1], strings.Join(path[2:], "/") + } + acc := ctx.Locals("account").(auth.Account) return EventSchema{ diff --git a/s3log/file.go b/s3log/file.go index 9d36fff..3254caf 100644 --- a/s3log/file.go +++ b/s3log/file.go @@ -68,7 +68,10 @@ func (f *FileLogger) Log(ctx *fiber.Ctx, err error, body []byte, meta LogMeta) { access := "-" reqURI := ctx.OriginalURL() path := strings.Split(ctx.Path(), "/") - bucket, object := path[1], strings.Join(path[2:], "/") + var bucket, object string + if len(path) > 1 { + bucket, object = path[1], strings.Join(path[2:], "/") + } errorCode := "" httpStatus := 200 startTime := ctx.Locals("startTime").(time.Time) diff --git a/s3log/webhook.go b/s3log/webhook.go index 1fe7cb6..c0e52af 100644 --- a/s3log/webhook.go +++ b/s3log/webhook.go @@ -65,7 +65,10 @@ func (wl *WebhookLogger) Log(ctx *fiber.Ctx, err error, body []byte, meta LogMet access := "-" reqURI := ctx.OriginalURL() path := strings.Split(ctx.Path(), "/") - bucket, object := path[1], strings.Join(path[2:], "/") + var bucket, object string + if len(path) > 1 { + bucket, object = path[1], strings.Join(path[2:], "/") + } errorCode := "" httpStatus := 200 startTime := ctx.Locals("startTime").(time.Time)