Restructure the go package

develop
Nikita Tokarchuk 3 years ago
parent a9b5ac4df2
commit 39ef200967
Signed by: mainnika
GPG Key ID: A595FB7E3E56911C
  1. 2
      Dockerfile
  2. 15
      cmd/renderer/main.go
  3. 13
      frontend/ghost/ghost.go
  4. 0
      pkg/config/config.go
  5. 8
      pkg/content/blog.go
  6. 0
      pkg/content/error.go
  7. 10
      pkg/content/index.go
  8. 4
      pkg/ghost/data/data.go
  9. 42
      pkg/ghost/data/data_easyjson.go
  10. 16
      pkg/ghost/ghost.go
  11. 2
      pkg/ghost/params/params.go
  12. 36
      pkg/ghost/v4api/httpclient/client.go
  13. 14
      pkg/routes/blog.go
  14. 9
      pkg/routes/error.go
  15. 15
      pkg/routes/index.go
  16. 7
      pkg/routes/output.go
  17. 16
      pkg/routes/routes.go
  18. 0
      pkg/templates/blog.go.tmpl
  19. 0
      pkg/templates/error.go.tmpl
  20. 0
      pkg/templates/funcs.go
  21. 0
      pkg/templates/head.go.tmpl
  22. 0
      pkg/templates/index.go.tmpl
  23. 0
      pkg/templates/menu.go.tmpl
  24. 0
      pkg/templates/post.go.tmpl
  25. 0
      pkg/templates/templates.go
  26. 0
      pkg/templates/urls.go

@ -22,7 +22,7 @@ RUN --mount=type=cache,id=gopath,target=${GOPATH} \
go build \
-o nikita-tokarch-uk-frontend \
-ldflags "-X main.Version=${APP_VERSION}" \
code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend
code.tokarch.uk/mainnika/nikita-tokarch-uk/cmd/renderer
FROM registry.access.redhat.com/ubi8/ubi as js-builder

@ -9,11 +9,10 @@ import (
"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"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/v4api/httpclient"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/routes"
_ "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
)
var Version = "nightly"
@ -53,7 +52,7 @@ func main() {
logrus.Fatal(err)
}
ghostClient := &ghost.HTTPClient{
ghostClient := &httpclient.HTTPClient{
Addr: config.Content.Backend.Addr,
Secured: config.Content.Backend.Secured,
Headers: config.Content.Backend.Headers,
@ -61,7 +60,7 @@ func main() {
QueryTimeout: time.Second,
}
rendererHandler := &renderer.Renderer{
apiRoutes := &routes.Routes{
GhostClient: ghostClient,
ContentConfig: config.Content,
Base: config.Base,
@ -69,7 +68,7 @@ func main() {
httpServer := fasthttp.Server{
Logger: logrus.StandardLogger(),
Handler: rendererHandler.Handler,
Handler: apiRoutes.Handler,
Name: frontendServerIdentity,
GetOnly: true,
}

@ -1,13 +0,0 @@
package ghost
//go:generate $GOPATH/bin/easyjson -pkg -no_std_marshalers
// Client is the ghost backend client
type Client interface {
// GetPosts returns blog posts according to query params
GetPosts(queryParams ...Modifier) (posts *Posts, err error)
// GetPostBySlug returns a single post by its slug title and query params
GetPostBySlug(slug string, queryParams ...Modifier) (posts *Posts, err error)
// GetPageBySlug returns a single page by its slug title and query params
GetPageBySlug(slug string, queryParams ...Modifier) (pages *Pages, err error)
}

@ -3,15 +3,15 @@ package content
import (
"fmt"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/data"
)
// Blog content data
type Blog struct {
_ interface{} `template:"blog.go.tmpl"`
ghost.Meta
Pinned []ghost.Post
Posts []ghost.Post
data.Meta
Pinned []data.Post
Posts []data.Post
}
// Title returns blog content title

@ -1,15 +1,13 @@
package content
import (
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost"
)
import "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/data"
// Index content data
type Index struct {
_ interface{} `template:"index.go.tmpl"`
ghost.Meta
Pinned []ghost.Post
Posts []ghost.Post
data.Meta
Pinned []data.Post
Posts []data.Post
}
// Title returns index title

@ -1,4 +1,6 @@
package ghost
package data
//go:generate $GOPATH/bin/easyjson -pkg -no_std_marshalers
import "html/template"

@ -1,6 +1,6 @@
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
package ghost
package data
import (
json "encoding/json"
@ -18,7 +18,7 @@ var (
_ easyjson.Marshaler
)
func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost(in *jlexer.Lexer, out *Posts) {
func easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData(in *jlexer.Lexer, out *Posts) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
@ -72,7 +72,7 @@ func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost(in
in.Consumed()
}
}
func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost(out *jwriter.Writer, in Posts) {
func easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData(out *jwriter.Writer, in Posts) {
out.RawByte('{')
first := true
_ = first
@ -102,14 +102,14 @@ func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost(out
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Posts) MarshalEasyJSON(w *jwriter.Writer) {
easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost(w, v)
easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData(w, v)
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Posts) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost(l, v)
easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData(l, v)
}
func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost1(in *jlexer.Lexer, out *Post) {
func easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData1(in *jlexer.Lexer, out *Post) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
@ -148,7 +148,7 @@ func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost1(in
in.Consumed()
}
}
func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost1(out *jwriter.Writer, in Post) {
func easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData1(out *jwriter.Writer, in Post) {
out.RawByte('{')
first := true
_ = first
@ -182,14 +182,14 @@ func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost1(ou
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Post) MarshalEasyJSON(w *jwriter.Writer) {
easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost1(w, v)
easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData1(w, v)
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Post) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost1(l, v)
easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData1(l, v)
}
func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost2(in *jlexer.Lexer, out *Pagination) {
func easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData2(in *jlexer.Lexer, out *Pagination) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
@ -226,7 +226,7 @@ func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost2(in
in.Consumed()
}
}
func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost2(out *jwriter.Writer, in Pagination) {
func easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData2(out *jwriter.Writer, in Pagination) {
out.RawByte('{')
first := true
_ = first
@ -255,14 +255,14 @@ func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost2(ou
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Pagination) MarshalEasyJSON(w *jwriter.Writer) {
easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost2(w, v)
easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData2(w, v)
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Pagination) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost2(l, v)
easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData2(l, v)
}
func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost3(in *jlexer.Lexer, out *Pages) {
func easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData3(in *jlexer.Lexer, out *Pages) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
@ -316,7 +316,7 @@ func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost3(in
in.Consumed()
}
}
func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost3(out *jwriter.Writer, in Pages) {
func easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData3(out *jwriter.Writer, in Pages) {
out.RawByte('{')
first := true
_ = first
@ -346,14 +346,14 @@ func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost3(ou
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Pages) MarshalEasyJSON(w *jwriter.Writer) {
easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost3(w, v)
easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData3(w, v)
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Pages) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost3(l, v)
easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData3(l, v)
}
func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost4(in *jlexer.Lexer, out *Meta) {
func easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData4(in *jlexer.Lexer, out *Meta) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
@ -384,7 +384,7 @@ func easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost4(in
in.Consumed()
}
}
func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost4(out *jwriter.Writer, in Meta) {
func easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData4(out *jwriter.Writer, in Meta) {
out.RawByte('{')
first := true
_ = first
@ -398,10 +398,10 @@ func easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost4(ou
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Meta) MarshalEasyJSON(w *jwriter.Writer) {
easyjson72852e1bEncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost4(w, v)
easyjson794297d0EncodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData4(w, v)
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Meta) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson72852e1bDecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhost4(l, v)
easyjson794297d0DecodeCodeTokarchUkMainnikaNikitaTokarchUkFrontendGhostData4(l, v)
}

@ -0,0 +1,16 @@
package ghost
import (
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/data"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
)
// Client is the ghost backend client
type Client interface {
// GetPosts returns blog posts according to query params
GetPosts(queryParams ...params.Modifier) (posts *data.Posts, err error)
// GetPostBySlug returns a single post by its slug title and query params
GetPostBySlug(slug string, queryParams ...params.Modifier) (posts *data.Posts, err error)
// GetPageBySlug returns a single page by its slug title and query params
GetPageBySlug(slug string, queryParams ...params.Modifier) (pages *data.Pages, err error)
}

@ -1,4 +1,4 @@
package ghost
package params
// Params are generics query argument
type Params struct {

@ -1,4 +1,4 @@
package ghost
package httpclient
import (
"fmt"
@ -8,9 +8,13 @@ import (
"github.com/mailru/easyjson"
"github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/data"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
)
var _ Client = (*HTTPClient)(nil)
var _ ghost.Client = (*HTTPClient)(nil)
// Ghost content data URIs:
const (
@ -46,7 +50,7 @@ func (g *HTTPClient) setupClient() {
}
// doQuery does the method and unmarshals the result into the easyjson Unmarshaler
func (g *HTTPClient) doQuery(method string, v easyjson.Unmarshaler, params Params) (err error) {
func (g *HTTPClient) doQuery(path string, v easyjson.Unmarshaler, params params.Params) (err error) {
g.setupClientOnce.Do(g.setupClient)
@ -57,7 +61,7 @@ func (g *HTTPClient) doQuery(method string, v easyjson.Unmarshaler, params Param
fasthttp.ReleaseRequest(req)
}()
g.setupRequest(method, req)
g.setupRequest(path, req)
g.applyParams(params, req)
err = g.client.DoTimeout(req, res, g.QueryTimeout)
@ -103,7 +107,7 @@ func (g *HTTPClient) setupRequest(path string, req *fasthttp.Request) {
}
// applyParams function additionally configure the http request using params
func (g *HTTPClient) applyParams(p Params, req *fasthttp.Request) (err error) {
func (g *HTTPClient) applyParams(p params.Params, req *fasthttp.Request) (err error) {
uri := req.URI()
@ -121,10 +125,10 @@ func (g *HTTPClient) applyParams(p Params, req *fasthttp.Request) (err error) {
}
// GetPageBySlug returns the only one page using slug filter
func (g *HTTPClient) GetPageBySlug(slug string) (pages *Pages, err error) {
func (g *HTTPClient) GetPageBySlug(slug string, queryModifiers ...params.Modifier) (pages *data.Pages, err error) {
pages = &Pages{}
defaultParams := Params{}
pages = &data.Pages{}
defaultParams := params.Params{}
method := fmt.Sprintf(ghostAPIGetPageBySlug, slug)
err = g.doQuery(method, pages, defaultParams)
@ -136,11 +140,11 @@ func (g *HTTPClient) GetPageBySlug(slug string) (pages *Pages, err error) {
}
// GetPosts returns posts
func (g *HTTPClient) GetPosts(queryModifiers ...Modifier) (posts *Posts, err error) {
func (g *HTTPClient) GetPosts(queryModifiers ...params.Modifier) (posts *data.Posts, err error) {
posts = &Posts{}
defaultParams := Params{}
combinedParams := Modifiers(queryModifiers).Apply(defaultParams)
posts = &data.Posts{}
defaultParams := params.Params{}
combinedParams := params.Modifiers(queryModifiers).Apply(defaultParams)
err = g.doQuery(ghostAPIGetPosts, posts, combinedParams)
if err != nil {
@ -151,11 +155,11 @@ func (g *HTTPClient) GetPosts(queryModifiers ...Modifier) (posts *Posts, err err
}
// GetPostBySlug returns the only one post using slug filter
func (g *HTTPClient) GetPostBySlug(slug string, queryModifiers ...Modifier) (posts *Posts, err error) {
func (g *HTTPClient) GetPostBySlug(slug string, queryModifiers ...params.Modifier) (posts *data.Posts, err error) {
posts = &Posts{}
defaultParams := Params{}
combinedParams := Modifiers(queryModifiers).Apply(defaultParams)
posts = &data.Posts{}
defaultParams := params.Params{}
combinedParams := params.Modifiers(queryModifiers).Apply(defaultParams)
method := fmt.Sprintf(ghostAPIGetPostBySlug, slug)
err = g.doQuery(method, posts, combinedParams)

@ -1,18 +1,22 @@
package renderer
package routes
import (
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/content"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost"
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
)
// blog handler renders blog data
func (r *Renderer) blog(c *routing.Context) (err error) {
func (r *Routes) blog(c *routing.Context) (err error) {
postsPerPage := r.ContentConfig.PostsPerPage
currentPage := c.QueryArgs().GetUintOrZero("page")
latestPosts, err := r.GhostClient.GetPosts(ghost.QueryLimit(postsPerPage), ghost.QueryPage(currentPage))
latestPosts, err := r.GhostClient.GetPosts(
params.WithLimit(postsPerPage),
params.WithPage(currentPage),
)
if err != nil {
return
}

@ -1,16 +1,17 @@
package renderer
package routes
import (
"fmt"
"net/http"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/content"
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"github.com/sirupsen/logrus"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
)
// errorNotFound renders http error-404 template
func (r *Renderer) errorNotFound(c *routing.Context) (err error) {
func (r *Routes) errorNotFound(c *routing.Context) (err error) {
errorContent := content.Error{Message: "not found"}
@ -18,7 +19,7 @@ func (r *Renderer) errorNotFound(c *routing.Context) (err error) {
}
// useErrorHandler is the middleware that catch handlers errors and render error template
func (r *Renderer) useErrorHandler(c *routing.Context) (err error) {
func (r *Routes) useErrorHandler(c *routing.Context) (err error) {
worker := func() (err error) {

@ -1,16 +1,17 @@
package renderer
package routes
import (
"net/http"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/content"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/templates"
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
)
// rootRedirect redirects the root url to the index using http redirect
func (r *Renderer) rootRedirect(c *routing.Context) (err error) {
func (r *Routes) rootRedirect(c *routing.Context) (err error) {
c.Redirect(templates.URLIndex, http.StatusFound)
@ -18,7 +19,7 @@ func (r *Renderer) rootRedirect(c *routing.Context) (err error) {
}
// index handler renders index data
func (r *Renderer) index(c *routing.Context) (err error) {
func (r *Routes) index(c *routing.Context) (err error) {
pinnedPageSlug := r.ContentConfig.Pinned
postsPerPage := r.ContentConfig.PostsPerPage
@ -28,7 +29,7 @@ func (r *Renderer) index(c *routing.Context) (err error) {
return
}
latestPosts, err := r.GhostClient.GetPosts(ghost.QueryLimit(postsPerPage))
latestPosts, err := r.GhostClient.GetPosts(params.WithLimit(postsPerPage))
if err != nil {
return
}

@ -1,11 +1,12 @@
package renderer
package routes
import (
"io"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/templates"
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
)
var _ routing.DataWriter = (*TemplateWriter)(nil)
@ -30,7 +31,7 @@ func (tw *TemplateWriter) Write(w io.Writer, content interface{}) error {
}
// useTemplateWriter is the routing middleware to set the default data writer
func (r *Renderer) useTemplateWriter(c *routing.Context) (err error) {
func (r *Routes) useTemplateWriter(c *routing.Context) (err error) {
c.SetDataWriter(staticWriter)

@ -1,4 +1,4 @@
package renderer
package routes
import (
"sync"
@ -6,13 +6,13 @@ import (
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"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/templates"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
)
// Renderer is the main handler that contains all routes handlers
type Renderer struct {
// Routes is the main handler that contains all routes handlers
type Routes struct {
GhostClient ghost.Client
ContentConfig config.Content
@ -25,13 +25,13 @@ type Renderer struct {
}
// Handler invokes the lazy once-initializer and then does the request
func (r *Renderer) Handler(ctx *fasthttp.RequestCtx) {
func (r *Routes) Handler(ctx *fasthttp.RequestCtx) {
r.initOnce.Do(r.init)
r.handler(ctx)
}
// init has the renderer initialization
func (r *Renderer) init() {
func (r *Routes) init() {
router := routing.New()
Loading…
Cancel
Save