summaryrefslogtreecommitdiff
path: root/srv/src/api/assets.go
diff options
context:
space:
mode:
Diffstat (limited to 'srv/src/api/assets.go')
-rw-r--r--srv/src/api/assets.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/srv/src/api/assets.go b/srv/src/api/assets.go
index 7065ff6..c1cd75e 100644
--- a/srv/src/api/assets.go
+++ b/srv/src/api/assets.go
@@ -50,16 +50,41 @@ func resizeImage(out io.Writer, in io.Reader, maxWidth float64) error {
}
}
+func (a *api) renderPostAssetsIndexHandler() http.Handler {
+
+ tpl := a.mustParseBasedTpl("assets.html")
+
+ return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
+
+ ids, err := a.params.PostAssetStore.List()
+
+ if err != nil {
+ apiutil.InternalServerError(
+ rw, r, fmt.Errorf("getting list of asset ids: %w", err),
+ )
+ return
+ }
+
+ tplPayload := struct {
+ IDs []string
+ }{
+ IDs: ids,
+ }
+
+ executeTemplate(rw, r, tpl, tplPayload)
+ })
+}
+
func (a *api) getPostAssetHandler() http.Handler {
- renderHandler := a.renderPostAssetsIndexHandler()
+ renderIndexHandler := a.renderPostAssetsIndexHandler()
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
id := filepath.Base(r.URL.Path)
if id == "/" {
- renderHandler.ServeHTTP(rw, r)
+ renderIndexHandler.ServeHTTP(rw, r)
return
}