From 4c04177c05355ddb92d3d31a4c5cfbaa86555a13 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 14 May 2022 16:14:11 -0600 Subject: Move template rendering logic into api package --- srv/src/api/api.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'srv/src/api/api.go') diff --git a/srv/src/api/api.go b/srv/src/api/api.go index 75147d5..92771a1 100644 --- a/srv/src/api/api.go +++ b/srv/src/api/api.go @@ -3,8 +3,10 @@ package api import ( "context" + "embed" "errors" "fmt" + "html/template" "net" "net/http" "net/http/httputil" @@ -20,14 +22,18 @@ import ( "github.com/mediocregopher/mediocre-go-lib/v2/mlog" ) +//go:embed tpl +var fs embed.FS + +var tpls = template.Must(template.ParseFS(fs, "tpl/*")) + // Params are used to instantiate a new API instance. All fields are required // unless otherwise noted. type Params struct { Logger *mlog.Logger PowManager pow.Manager - PostStore post.Store - PostHTTPRenderer post.Renderer + PostStore post.Store MailingList mailinglist.MailingList @@ -190,7 +196,7 @@ func (a *api) handler() http.Handler { mux.Handle("/api/", http.StripPrefix("/api", apiHandler)) - mux.Handle("/posts/", a.postHandler()) + mux.Handle("/v2/posts/", a.postHandler()) return mux } -- cgit v1.2.3