diff --git a/go.mod b/go.mod index 2c0a2a74cb295849f1c294f313d82626bb2b9c82..5a2ee4ad8e8c7869f2fb0aa0027da8c15dce497f 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( git.autistici.org/id/auth v0.0.0-20210110171913-dd493db32815 git.autistici.org/id/keystore v0.0.0-20210110165905-d5b171e81071 github.com/crewjam/saml v0.4.5 - github.com/elazarl/go-bindata-assetfs v1.0.0 + github.com/elazarl/go-bindata-assetfs v1.0.1 github.com/gorilla/csrf v1.7.0 github.com/gorilla/mux v1.7.3 github.com/gorilla/securecookie v1.1.1 diff --git a/go.sum b/go.sum index d6a0bb7b2d8eb574d0e7f30747a61dc702e21e63..51d22a97c882961b5710ec7c2321bd0505017b89 100644 --- a/go.sum +++ b/go.sum @@ -81,6 +81,8 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= +github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw= +github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= diff --git a/vendor/github.com/elazarl/go-bindata-assetfs/README.md b/vendor/github.com/elazarl/go-bindata-assetfs/README.md index 27ee48f09d9d4d4380583b3a5de30f5547db433c..b326dca196176252d789fd7291d36e0a0263b994 100644 --- a/vendor/github.com/elazarl/go-bindata-assetfs/README.md +++ b/vendor/github.com/elazarl/go-bindata-assetfs/README.md @@ -1,6 +1,6 @@ # go-bindata-assetfs -Serve embedded files from [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) with `net/http`. +Serve embedded files from [go-bindata](https://github.com/go-bindata/go-bindata) with `net/http`. [GoDoc](http://godoc.org/github.com/elazarl/go-bindata-assetfs) @@ -8,12 +8,12 @@ Serve embedded files from [jteeuwen/go-bindata](https://github.com/jteeuwen/go-b Install with - $ go get github.com/jteeuwen/go-bindata/... + $ go get github.com/go-bindata/go-bindata/... $ go get github.com/elazarl/go-bindata-assetfs/... ### Creating embedded data -Usage is identical to [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) usage, +Usage is identical to [go-bindata](https://github.com/go-bindata/go-bindata) usage, instead of running `go-bindata` run `go-bindata-assetfs`. The tool will create a `bindata_assetfs.go` file, which contains the embedded data. @@ -37,10 +37,26 @@ You can always just run the `go-bindata` tool, and then use - import "github.com/elazarl/go-bindata-assetfs" - ... - http.Handle("/", - http.FileServer( - &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: "data"})) +```go +import "github.com/elazarl/go-bindata-assetfs" +... +http.Handle("/", +http.FileServer( +&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: "data"})) +``` to serve files embedded from the `data` directory. + +## SPA applications + +For single page applications you can use `Fallback: "index.html"` in AssetFS context, so if route doesn't match the pattern it will fallback to file specified. + +example + +```go +import "github.com/elazarl/go-bindata-assetfs" +... +http.Handle("/", +http.FileServer( +&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: "data", Fallback: "index.html"})) +``` diff --git a/vendor/github.com/elazarl/go-bindata-assetfs/assetfs.go b/vendor/github.com/elazarl/go-bindata-assetfs/assetfs.go index 04f6d7a39d9c12da5ebe7f83eaa48336aa48d610..81874973d3a5ea16c3bf94f3e3c1b7a81c519bd3 100644 --- a/vendor/github.com/elazarl/go-bindata-assetfs/assetfs.go +++ b/vendor/github.com/elazarl/go-bindata-assetfs/assetfs.go @@ -137,6 +137,8 @@ type AssetFS struct { AssetInfo func(path string) (os.FileInfo, error) // Prefix would be prepended to http requests Prefix string + // Fallback file that is served if no other is found + Fallback string } func (fs *AssetFS) Open(name string) (http.File, error) { @@ -153,9 +155,13 @@ func (fs *AssetFS) Open(name string) (http.File, error) { } return NewAssetFile(name, b, timestamp), nil } - if children, err := fs.AssetDir(name); err == nil { - return NewAssetDirectory(name, children, fs), nil - } else { + children, err := fs.AssetDir(name) + + if err != nil { + if len(fs.Fallback) > 0 { + return fs.Open(fs.Fallback) + } + // If the error is not found, return an error that will // result in a 404 error. Otherwise the server returns // a 500 error for files not found. @@ -164,4 +170,6 @@ func (fs *AssetFS) Open(name string) (http.File, error) { } return nil, err } + + return NewAssetDirectory(name, children, fs), nil } diff --git a/vendor/github.com/elazarl/go-bindata-assetfs/doc.go b/vendor/github.com/elazarl/go-bindata-assetfs/doc.go index a664249f342b6343a82287a592b4e614817dea69..8f8f2c3dbe8c188dbc250b1c8b581df2f4bd5ac0 100644 --- a/vendor/github.com/elazarl/go-bindata-assetfs/doc.go +++ b/vendor/github.com/elazarl/go-bindata-assetfs/doc.go @@ -1,7 +1,7 @@ // assetfs allows packages to serve static content embedded // with the go-bindata tool with the standard net/http package. // -// See https://github.com/jteeuwen/go-bindata for more information +// See https://github.com/go-bindata/go-bindata for more information // about embedding binary data with go-bindata. // // Usage example, after running diff --git a/vendor/modules.txt b/vendor/modules.txt index 41125730b7fdd0101a8cf507ca075491d29af985..9a7ab0e37a405c52a1efb559d6e78c90de86189d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -30,7 +30,7 @@ github.com/coreos/go-systemd/v22/daemon github.com/crewjam/saml github.com/crewjam/saml/logger github.com/crewjam/saml/xmlenc -# github.com/elazarl/go-bindata-assetfs v1.0.0 +# github.com/elazarl/go-bindata-assetfs v1.0.1 ## explicit github.com/elazarl/go-bindata-assetfs # github.com/felixge/httpsnoop v1.0.1 @@ -99,8 +99,6 @@ github.com/rs/cors github.com/russellhaering/goxmldsig github.com/russellhaering/goxmldsig/etreeutils github.com/russellhaering/goxmldsig/types -# github.com/satori/go.uuid v1.2.0 -## explicit # github.com/theckman/go-flock v0.8.0 github.com/theckman/go-flock # github.com/tstranex/u2f v1.0.0