diff options
Diffstat (limited to 'srv/src/http/drafts.go')
-rw-r--r-- | srv/src/http/drafts.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/srv/src/http/drafts.go b/srv/src/http/drafts.go index 8bb08e5..cb776b0 100644 --- a/srv/src/http/drafts.go +++ b/srv/src/http/drafts.go @@ -108,3 +108,23 @@ func (a *api) renderDraftPostsIndexHandler() http.Handler { executeTemplate(rw, r, tpl, tplPayload) }) } + +func (a *api) postDraftPostHandler() http.Handler { + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + + p, err := postFromPostReq(r) + if err != nil { + apiutil.BadRequest(rw, r, err) + return + } + + if err := a.params.PostDraftStore.Set(p); err != nil { + apiutil.InternalServerError( + rw, r, fmt.Errorf("storing post with id %q: %w", p.ID, err), + ) + return + } + + a.executeRedirectTpl(rw, r, a.draftURL(p.ID, false)+"?edit") + }) +} |