Compare commits

..

2 Commits

Author SHA1 Message Date
Max Richter
a5acef77a2 feat: add about and url to article template 2025-10-04 12:33:36 +02:00
Max Richter
74528625e3 feat: handle binary content 2025-10-04 12:31:40 +02:00
4 changed files with 10 additions and 10 deletions

View File

@@ -11,6 +11,8 @@
codec: const codec: const
value: Article value: Article
- path: image - path: image
- path: about
- path: url
- path: author.name - path: author.name
- path: author._type - path: author._type
codec: const codec: const

View File

@@ -174,4 +174,3 @@ func NewLocalFsAdapter(roots []string) (FileAdapter, error) {
roots: roots, roots: roots,
}, nil }, nil
} }

View File

@@ -3,6 +3,8 @@ package handler
import ( import (
"encoding/json" "encoding/json"
"net/http" "net/http"
"git.max-richter.dev/max/marka/server-new/internal/adapters"
) )
type ErrorResponse struct { type ErrorResponse struct {
@@ -18,3 +20,8 @@ func writeJSON(w http.ResponseWriter, code int, v any) {
w.WriteHeader(code) w.WriteHeader(code)
_ = json.NewEncoder(w).Encode(v) _ = json.NewEncoder(w).Encode(v)
} }
func writeFile(w http.ResponseWriter, file *adapters.FsFile) {
w.Header().Set("Content-Type", file.Type)
w.Write(file.Content)
}

View File

@@ -52,15 +52,7 @@ func (h *Handler) get(w http.ResponseWriter, target string) {
return return
} }
res := ResponseItem{ writeFile(w, fsEntry.File)
Name: fsEntry.File.Name,
Content: fsEntry.File.Content,
Type: fsEntry.File.Type,
IsDir: false,
Size: int64(len(fsEntry.File.Content)),
ModTime: fsEntry.File.ModTime,
}
writeJSON(w, 200, res)
return return
} }