From 7e87c09c50983a25ed7c9816e11a856903ed89d5 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 13 May 2022 13:35:54 -0600 Subject: Add /posts handler to api --- srv/src/cmd/mediocre-blog/main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'srv/src/cmd') diff --git a/srv/src/cmd/mediocre-blog/main.go b/srv/src/cmd/mediocre-blog/main.go index 69ee7b6..28571a3 100644 --- a/srv/src/cmd/mediocre-blog/main.go +++ b/srv/src/cmd/mediocre-blog/main.go @@ -11,6 +11,7 @@ import ( cfgpkg "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg" "github.com/mediocregopher/blog.mediocregopher.com/srv/chat" "github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist" + "github.com/mediocregopher/blog.mediocregopher.com/srv/post" "github.com/mediocregopher/blog.mediocregopher.com/srv/pow" "github.com/mediocregopher/mediocre-go-lib/v2/mctx" "github.com/mediocregopher/mediocre-go-lib/v2/mlog" @@ -112,8 +113,18 @@ func main() { chatUserIDCalc := chat.NewUserIDCalculator([]byte(*chatUserIDCalcSecret)) + postSQLDB, err := post.NewSQLDB(dataDir) + if err != nil { + logger.Fatal(ctx, "initializing sql db for post data", err) + } + defer postSQLDB.Close() + + postStore := post.NewStore(postSQLDB) + apiParams.Logger = logger.WithNamespace("api") apiParams.PowManager = powMgr + apiParams.PostStore = postStore + apiParams.PostHTTPRenderer = post.NewMarkdownToHTMLRenderer() apiParams.MailingList = ml apiParams.GlobalRoom = chatGlobalRoom apiParams.UserIDCalculator = chatUserIDCalc -- cgit v1.2.3