pkg/pools: Use pool for strings.Builder everywhere

This commit is contained in:
Tom Wiesing 2023-01-24 10:52:15 +01:00
parent 8af2213d5a
commit a63bb2f669
No known key found for this signature in database
7 changed files with 44 additions and 25 deletions

View file

@ -12,6 +12,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/templating"
"github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
"github.com/FAU-CDI/wisski-distillery/pkg/pools"
)
//go:embed "public.html"
@ -58,13 +59,17 @@ func (home *Home) publicHandler(ctx context.Context) http.Handler {
return pc, httpx.ErrNotFound
}
// get a builder
builder := pools.GetBuilder()
defer pools.ReleaseBuilder(builder)
// prepare about
pc.aboutContext.Instances = home.homeInstances.Get(nil)
pc.aboutContext.SelfRedirect = home.Config.SelfRedirect.String()
// render the about template
var builder strings.Builder
if err := about.Execute(&builder, pc.aboutContext); err != nil {
if err := about.Execute(builder, pc.aboutContext); err != nil {
return pc, nil
}