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
value: Article
- path: image
- path: about
- path: url
- path: author.name
- path: author._type
codec: const

View File

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

View File

@@ -3,6 +3,8 @@ package handler
import (
"encoding/json"
"net/http"
"git.max-richter.dev/max/marka/server-new/internal/adapters"
)
type ErrorResponse struct {
@@ -18,3 +20,8 @@ func writeJSON(w http.ResponseWriter, code int, v any) {
w.WriteHeader(code)
_ = 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
}
res := ResponseItem{
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)
writeFile(w, fsEntry.File)
return
}