Commit f566e4d

Eric Bower  ·  2026-04-20 21:32:16 -0400 EDT
parent 5f240f0
refactor(storage): no need for metadata just need content type
5 files changed,  +5, -11
+1, -1
......@@ -257,7 +257,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
257257
258258 contentType := ""
259259 if info != nil {
260- contentType = info.Metadata.Get("content-type")
260+ contentType = info.ContentType
261261 if info.Size != 0 {
262262 w.Header().Add("content-length", strconv.Itoa(int(info.Size)))
263263 }
+1, -4
......@@ -104,10 +104,7 @@ func newTestStorage(st storage.StorageServe) *testStorage {
104104
105105 func (t *testStorage) GetObject(bucket storage.Bucket, fpath string) (utils.ReadAndReaderAtCloser, *storage.ObjectInfo, error) {
106106 r, info, err := t.StorageServe.GetObject(bucket, fpath)
107- if info.Metadata == nil {
108- info.Metadata = make(http.Header)
109- }
110- info.Metadata.Set("content-type", mime.GetMimeType(fpath))
107+ info.ContentType = mime.GetMimeType(fpath)
111108 info.LastModified = time.Now().UTC()
112109 info.ETag = "static-etag-for-testing-purposes"
113110 return r, info, err
+2, -3
......@@ -7,7 +7,6 @@ import (
77 "io"
88 "io/fs"
99 "log/slog"
10- "net/http"
1110 "os"
1211 "path"
1312 "path/filepath"
......@@ -106,8 +105,8 @@ func (s *StorageFS) GetObject(bucket Bucket, fpath string) (utils.ReadAndReaderA
106105 objInfo := &ObjectInfo{
107106 Size: 0,
108107 LastModified: time.Time{},
109- Metadata: make(http.Header),
110108 ETag: "",
109+ ContentType: "",
111110 }
112111
113112 dat, err := os.Open(filepath.Join(bucket.Path, fpath))
......@@ -144,7 +143,7 @@ func (s *StorageFS) GetObject(bucket Bucket, fpath string) (utils.ReadAndReaderA
144143 objInfo.ETag = etag
145144 objInfo.Size = info.Size()
146145 objInfo.LastModified = info.ModTime()
147- objInfo.Metadata.Set("content-type", mime.GetMimeType(fpath))
146+ objInfo.ContentType = mime.GetMimeType(fpath)
148147 return dat, objInfo, nil
149148 }
150149
+0, -1
......@@ -93,7 +93,6 @@ func (s *StorageMemory) GetObject(bucket Bucket, fpath string) (utils.ReadAndRea
9393
9494 objInfo := &ObjectInfo{
9595 LastModified: time.Time{},
96- Metadata: nil,
9796 }
9897
9998 dat, ok := s.storage[bucket.Path][fpath]
+1, -2
......@@ -2,7 +2,6 @@ package storage
22
33 import (
44 "io"
5- "net/http"
65 "os"
76 "time"
87
......@@ -19,7 +18,7 @@ type ObjectInfo struct {
1918 Size int64
2019 LastModified time.Time
2120 ETag string
22- Metadata http.Header
21+ ContentType string
2322 }
2423
2524 type BucketStorage interface {