Skip to content

wolfeidau/echo-s3-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

echo-s3-middleware

This echo middleware provides a static file store backed by S3.

GitHub Actions status Go Report Card Documentation

Example

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"))

License

This code was authored by Mark Wolfe and licensed under the Apache 2.0 license.