repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
f566e4d
parent
5f240f0
author
Eric Bower
date
2026-04-20 21:32:16 -0400 EDT
refactor(storage): no need for metadata just need content type
5 files changed,  +5, -11
M pkg/apps/pgs/web_asset_handler.go
+1, -1
1@@ -257,7 +257,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
2 
3 	contentType := ""
4 	if info != nil {
5-		contentType = info.Metadata.Get("content-type")
6+		contentType = info.ContentType
7 		if info.Size != 0 {
8 			w.Header().Add("content-length", strconv.Itoa(int(info.Size)))
9 		}
M pkg/apps/pgs/web_test.go
+1, -4
 1@@ -104,10 +104,7 @@ func newTestStorage(st storage.StorageServe) *testStorage {
 2 
 3 func (t *testStorage) GetObject(bucket storage.Bucket, fpath string) (utils.ReadAndReaderAtCloser, *storage.ObjectInfo, error) {
 4 	r, info, err := t.StorageServe.GetObject(bucket, fpath)
 5-	if info.Metadata == nil {
 6-		info.Metadata = make(http.Header)
 7-	}
 8-	info.Metadata.Set("content-type", mime.GetMimeType(fpath))
 9+	info.ContentType = mime.GetMimeType(fpath)
10 	info.LastModified = time.Now().UTC()
11 	info.ETag = "static-etag-for-testing-purposes"
12 	return r, info, err
M pkg/storage/fs.go
+2, -3
 1@@ -7,7 +7,6 @@ import (
 2 	"io"
 3 	"io/fs"
 4 	"log/slog"
 5-	"net/http"
 6 	"os"
 7 	"path"
 8 	"path/filepath"
 9@@ -106,8 +105,8 @@ func (s *StorageFS) GetObject(bucket Bucket, fpath string) (utils.ReadAndReaderA
10 	objInfo := &ObjectInfo{
11 		Size:         0,
12 		LastModified: time.Time{},
13-		Metadata:     make(http.Header),
14 		ETag:         "",
15+		ContentType:  "",
16 	}
17 
18 	dat, err := os.Open(filepath.Join(bucket.Path, fpath))
19@@ -144,7 +143,7 @@ func (s *StorageFS) GetObject(bucket Bucket, fpath string) (utils.ReadAndReaderA
20 	objInfo.ETag = etag
21 	objInfo.Size = info.Size()
22 	objInfo.LastModified = info.ModTime()
23-	objInfo.Metadata.Set("content-type", mime.GetMimeType(fpath))
24+	objInfo.ContentType = mime.GetMimeType(fpath)
25 	return dat, objInfo, nil
26 }
27 
M pkg/storage/memory.go
+0, -1
1@@ -93,7 +93,6 @@ func (s *StorageMemory) GetObject(bucket Bucket, fpath string) (utils.ReadAndRea
2 
3 	objInfo := &ObjectInfo{
4 		LastModified: time.Time{},
5-		Metadata:     nil,
6 	}
7 
8 	dat, ok := s.storage[bucket.Path][fpath]
M pkg/storage/storage.go
+1, -2
 1@@ -2,7 +2,6 @@ package storage
 2 
 3 import (
 4 	"io"
 5-	"net/http"
 6 	"os"
 7 	"time"
 8 
 9@@ -19,7 +18,7 @@ type ObjectInfo struct {
10 	Size         int64
11 	LastModified time.Time
12 	ETag         string
13-	Metadata     http.Header
14+	ContentType  string
15 }
16 
17 type BucketStorage interface {