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