https://github.com/wolfeidau/echo-s3-middleware
This echo middleware provides a static file store backed by S3.
https://github.com/wolfeidau/echo-s3-middleware
aws echo-middleware golang s3
Last synced: about 1 month ago
JSON representation
This echo middleware provides a static file store backed by S3.
- Host: GitHub
- URL: https://github.com/wolfeidau/echo-s3-middleware
- Owner: wolfeidau
- License: apache-2.0
- Created: 2020-04-11T03:50:37.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-17T00:05:01.000Z (over 5 years ago)
- Last Synced: 2025-01-19T06:29:11.745Z (over 1 year ago)
- Topics: aws, echo-middleware, golang, s3
- Language: Go
- Homepage: https://github.com/wolfeidau/echo-s3-middleware
- Size: 52.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# echo-s3-middleware
This [echo](https://echo.labstack.com/) middleware provides a static file store backed by S3.
[](https://github.com/wolfeidau/echo-s3-middleware/actions?query=workflow%3AGo)
[](https://goreportcard.com/report/github.com/wolfeidau/echo-s3-middleware)
[](https://pkg.go.dev/github.com/wolfeidau/echo-s3-middleware)
# Example
```go
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](https://www.wolfe.id.au) and licensed under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0).