Compare commits
2 Commits
ab81c980b5
...
a5acef77a2
Author | SHA1 | Date | |
---|---|---|---|
|
a5acef77a2
|
||
|
74528625e3
|
@@ -11,6 +11,8 @@
|
||||
codec: const
|
||||
value: Article
|
||||
- path: image
|
||||
- path: about
|
||||
- path: url
|
||||
- path: author.name
|
||||
- path: author._type
|
||||
codec: const
|
||||
|
@@ -174,4 +174,3 @@ func NewLocalFsAdapter(roots []string) (FileAdapter, error) {
|
||||
roots: roots,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user