diff options
author | Bwko <bouwko@gmail.com> | 2017-01-25 05:26:31 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-01-25 12:26:31 +0800 |
commit | 8555e888d8690df718b1673b8409a29d05770cf4 (patch) | |
tree | 19b7cb9e6f548b87aef122b66f99e04dcfe36335 /vendor/gopkg.in/macaron.v1/render.go | |
parent | 8093b3372e812af6a5c3aab32559881011861243 (diff) | |
download | gitea-8555e888d8690df718b1673b8409a29d05770cf4.tar.gz gitea-8555e888d8690df718b1673b8409a29d05770cf4.zip |
Add ETag header to avatars (#721)
Diffstat (limited to 'vendor/gopkg.in/macaron.v1/render.go')
-rw-r--r-- | vendor/gopkg.in/macaron.v1/render.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/vendor/gopkg.in/macaron.v1/render.go b/vendor/gopkg.in/macaron.v1/render.go index ff2dcaacdd..f45e431240 100644 --- a/vendor/gopkg.in/macaron.v1/render.go +++ b/vendor/gopkg.in/macaron.v1/render.go @@ -21,6 +21,7 @@ import ( "encoding/xml" "fmt" "html/template" + "io" "io/ioutil" "net/http" "os" @@ -72,6 +73,7 @@ type ( // TemplateFileSystem represents a interface of template file system that able to list all files. TemplateFileSystem interface { ListFiles() []TemplateFile + Get(string) (io.Reader, error) } // Delims represents a set of Left and Right delimiters for HTML template rendering @@ -246,6 +248,15 @@ func (fs TplFileSystem) ListFiles() []TemplateFile { return fs.files } +func (fs TplFileSystem) Get(name string) (io.Reader, error) { + for i := range fs.files { + if fs.files[i].Name()+fs.files[i].Ext() == name { + return bytes.NewReader(fs.files[i].Data()), nil + } + } + return nil, fmt.Errorf("file '%s' not found", name) +} + func PrepareCharset(charset string) string { if len(charset) != 0 { return "; charset=" + charset |