diff --git a/frontend/ghost/client.go b/frontend/ghost/client.go index 504ca84..e9c089e 100644 --- a/frontend/ghost/client.go +++ b/frontend/ghost/client.go @@ -8,6 +8,9 @@ import ( "github.com/mailru/easyjson" "github.com/valyala/fasthttp" ) + +var _ Client = (*HTTPClient)(nil) + // Ghost content data URIs: const ( ghostAPIPrefix = "/ghost/api/v3/" diff --git a/frontend/main.go b/frontend/main.go index 8c5ee56..872703c 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -3,12 +3,14 @@ package main import ( "fmt" "net" + "time" "github.com/sirupsen/logrus" "github.com/spf13/viper" "github.com/valyala/fasthttp" "code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/config" + "code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost" "code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/renderer" _ "code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/templates" @@ -51,7 +53,15 @@ func main() { logrus.Fatal(err) } + ghostClient := &ghost.Client{ + Addr: config.Content.Backend, + ContentKey: config.Content.Key, + Secured: true, + QueryTimeout: time.Second, + } + rendererHandler := &renderer.Renderer{ + GhostClient: ghostClient, Base: config.Base, } diff --git a/frontend/renderer/renderer.go b/frontend/renderer/renderer.go index a141770..f9e3964 100644 --- a/frontend/renderer/renderer.go +++ b/frontend/renderer/renderer.go @@ -5,11 +5,14 @@ import ( routing "github.com/jackwhelpton/fasthttp-routing/v2" "github.com/valyala/fasthttp" + + "code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost" "code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/templates" ) // Renderer is the main handler that contains all routes handlers type Renderer struct { + GhostClient ghost.Client Base string router *routing.Router