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/api/api.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'srv/src/api/api.go') diff --git a/srv/src/api/api.go b/srv/src/api/api.go index 56f33b2..75147d5 100644 --- a/srv/src/api/api.go +++ b/srv/src/api/api.go @@ -14,6 +14,7 @@ import ( "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" @@ -22,9 +23,14 @@ import ( // 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 - MailingList mailinglist.MailingList + Logger *mlog.Logger + PowManager pow.Manager + + PostStore post.Store + PostHTTPRenderer post.Renderer + + MailingList mailinglist.MailingList + GlobalRoom chat.Room UserIDCalculator *chat.UserIDCalculator @@ -172,7 +178,7 @@ func (a *api) handler() http.Handler { ))) var apiHandler http.Handler = apiMux - apiHandler = postOnlyMiddleware(apiHandler) + apiHandler = postOnlyMiddleware(apiHandler) // TODO probably should be last? apiHandler = checkCSRFMiddleware(apiHandler) apiHandler = logMiddleware(a.params.Logger, apiHandler) apiHandler = annotateMiddleware(apiHandler) @@ -184,5 +190,7 @@ func (a *api) handler() http.Handler { mux.Handle("/api/", http.StripPrefix("/api", apiHandler)) + mux.Handle("/posts/", a.postHandler()) + return mux } -- cgit v1.2.3