This echo middleware provides a static file store backed by S3.
e := echo.New()
e.Pre(echomiddleware.AddTrailingSlash()) // required to ensure trailing slash is appended
fs := s3middleware.New(s3middleware.FilesConfig{
Region: "us-east-1", // can also be assigned using AWS_REGION environment variable
SPA: true, // enable fallback which will try Index if the first path is not found
Index: "login.html",
Summary: func(ctx context.Context, data map[string]interface{}) {
log.Printf("processed s3 request: %+v", data)
},
OnErr: func(ctx context.Context, err error) {
log.Printf("failed to process s3 request: %+v", err)
},
})
// serve static files from the supplied bucket
e.Use(fs.StaticBucket("somebucket"))
This code was authored by Mark Wolfe and licensed under the Apache 2.0 license.