Commits

Miki Tebeka committed e13d08b

Removing MimeType from resource interface

Comments (0)

Files changed (2)

 	"html/template"
 	"io"
 	"io/ioutil"
+	"mime"
 	"net/http"
 	"path/filepath"
 	"strings"
 type Resource interface {
 	Open() io.Reader
 	Size() int64
-	MimeType() string
 	ModTime() time.Time
 }
 
 type resource struct {
 	size  int64
 	mtime time.Time
-	mtype string
 	data  []byte
 }
 
 	return rsc.size
 }
 
-func (rsc *resource) MimeType() string {
-	return rsc.mtype
-}
-
 func (rsc *resource) ModTime() time.Time {
 	return rsc.mtime
 }
 		return
 	}
 
-	if len(rsc.MimeType()) != 0 {
-		w.Header().Set("Content-Type", rsc.MimeType())
+	mtype := mime.TypeByExtension(filepath.Ext(req.URL.Path))
+	if len(mtype) != 0 {
+		w.Header().Set("Content-Type", mtype)
 	}
 	w.Header().Set("Content-Size", fmt.Sprintf("%d", rsc.Size()))
 	w.Header().Set("Last-Modified", rsc.ModTime().UTC().Format(http.TimeFormat))
 	"fmt"
 	"io"
 	"io/ioutil"
-	"mime"
 	"os"
 	"path/filepath"
 	"strings"
 	fmt.Fprintf(out, "\t\"%s\": &resource{\n", key)
 	fmt.Fprintf(out, "\t\tsize: %d,\n", info.Size())
 	fmt.Fprintf(out, "\t\tmtime: time.Unix(%d, 0),\n", info.ModTime().Unix())
-	mtype := mime.TypeByExtension(filepath.Ext(path))
-	fmt.Fprintf(out, "\t\tmtype: \"%s\",\n", mtype)
 	fmt.Fprintf(out, "\t\tdata: []byte{")
 	for _, b := range data {
 		fmt.Fprintf(out, "%d, ", b)