Fix some small things

This commit is contained in:
Jan-Lukas Else 2022-01-26 19:59:09 +01:00
parent 5268529b12
commit 66cdf89863
3 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"io"
"log" "log"
"net/http" "net/http"
@ -42,7 +43,7 @@ func (a *goBlog) indexNowEnabled() bool {
} }
func (a *goBlog) serveIndexNow(w http.ResponseWriter, r *http.Request) { func (a *goBlog) serveIndexNow(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(a.indexNowKey())) _, _ = io.WriteString(w, a.indexNowKey())
} }
func (a *goBlog) indexNow(url string) { func (a *goBlog) indexNow(url string) {

View File

@ -79,7 +79,7 @@ func (a *goBlog) initMarkdown() {
func (a *goBlog) renderMarkdown(source string, absoluteLinks bool) (rendered []byte, err error) { func (a *goBlog) renderMarkdown(source string, absoluteLinks bool) (rendered []byte, err error) {
buffer := bufferpool.Get() buffer := bufferpool.Get()
a.renderMarkdownToWriter(buffer, source, absoluteLinks) err = a.renderMarkdownToWriter(buffer, source, absoluteLinks)
rendered = buffer.Bytes() rendered = buffer.Bytes()
bufferpool.Put(buffer) bufferpool.Put(buffer)
return return

View File

@ -128,10 +128,13 @@ func (a *goBlog) renderNewWithStatusCode(w http.ResponseWriter, r *http.Request,
// Write status code // Write status code
w.WriteHeader(statusCode) w.WriteHeader(statusCode)
// Render // Render
minWriter := a.min.Get().Writer(contenttype.HTML, w) buf := bufferpool.Get()
defer minWriter.Close() minWriter := a.min.Get().Writer(contenttype.HTML, buf)
hb := newHtmlBuilder(minWriter) hb := newHtmlBuilder(minWriter)
f(hb, data) f(hb, data)
_ = minWriter.Close()
_, _ = buf.WriteTo(w)
bufferpool.Put(buf)
} }
func (a *goBlog) checkRenderData(r *http.Request, data *renderData) { func (a *goBlog) checkRenderData(r *http.Request, data *renderData) {