use buffer to deliver sitemap
This commit is contained in:
10
main.go
10
main.go
@@ -29,7 +29,6 @@ import (
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/time/rate"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -1092,16 +1091,13 @@ func getSiteMap(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
tReader, tWriter := io.Pipe()
|
||||
|
||||
readBuf := new(bytes.Buffer)
|
||||
sm.Finalize()
|
||||
go func() {
|
||||
_, err = sm.WriteTo(tWriter)
|
||||
_, err = sm.WriteTo(readBuf)
|
||||
if err != nil {
|
||||
log.Warningf("error writing to pipe: %v", err)
|
||||
}
|
||||
}()
|
||||
c.DataFromReader(http.StatusOK, -1, "application/xml", tReader, nil)
|
||||
c.DataFromReader(http.StatusOK, int64(readBuf.Len()), "application/xml", readBuf, nil)
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user