Skip to content

jeffmhastings/s3dir

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

s3dir

Implements http.Dir.

This can be used to expose a s3 bucket (ex: for static assets).

Usage

package main
import (
  "net/http"

  "github.com/jeffmhastings/s3dir"
)

func main() {
	cfg := s3dir.BucketConfig{
		BucketName: "mah-bucket",
		Region:     "us-east-1",
	}

	bucket, err := s3dir.NewBucket(cfg)
	if err != nil {
		panic(err)
	}

  // note the trailing '/' when combining with http.StripPrefix
	http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(bucket)))
	http.ListenAndServe(":8080", nil)
}

License

MIT

About

S3 http.Dir implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%