summaryrefslogtreecommitdiff
path: root/srv/src/api/api.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-14 16:14:11 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-14 17:02:16 -0600
commit4c04177c05355ddb92d3d31a4c5cfbaa86555a13 (patch)
treed40a4dcb70ef84ba9356751a9bd96fed99f7f5d2 /srv/src/api/api.go
parentdd354bc323cd3176c9676444f99b33b69d0a2062 (diff)
Move template rendering logic into api package
Diffstat (limited to 'srv/src/api/api.go')
-rw-r--r--srv/src/api/api.go12
1 files changed, 9 insertions, 3 deletions
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
}