mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-05 14:07:01 +00:00
code format
This commit is contained in:
parent
cba996978e
commit
ae610d301a
1 changed files with 5 additions and 5 deletions
|
@ -60,7 +60,7 @@ func (f FileResponse) createHttpResponse(cacheKey string) (http.Header, int) {
|
||||||
header.Set(ContentLengthHeader, fmt.Sprintf("%d", len(f.Body)))
|
header.Set(ContentLengthHeader, fmt.Sprintf("%d", len(f.Body)))
|
||||||
header.Set(PagesCacheIndicatorHeader, "true")
|
header.Set(PagesCacheIndicatorHeader, "true")
|
||||||
|
|
||||||
log.Trace().Msgf("fileCache for '%s' used", cacheKey)
|
log.Trace().Msgf("fileCache for %q used", cacheKey)
|
||||||
return header, statusCode
|
return header, statusCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,19 +95,19 @@ func (t *writeCacheReader) Close() error {
|
||||||
fc.Body = t.buff.Bytes()
|
fc.Body = t.buff.Bytes()
|
||||||
_ = t.cache.Set(t.cacheKey, fc, fileCacheTimeout)
|
_ = t.cache.Set(t.cacheKey, fc, fileCacheTimeout)
|
||||||
}
|
}
|
||||||
log.Trace().Msgf("cacheReader for '%s' saved=%v closed", t.cacheKey, !t.hasErr)
|
log.Trace().Msgf("cacheReader for %q saved=%t closed", t.cacheKey, !t.hasErr)
|
||||||
return t.rc.Close()
|
return t.rc.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileResponse) CreateCacheReader(r io.ReadCloser, cache cache.SetGetKey, cacheKey string) io.ReadCloser {
|
func (f FileResponse) CreateCacheReader(r io.ReadCloser, cache cache.SetGetKey, cacheKey string) io.ReadCloser {
|
||||||
buf := []byte{}
|
|
||||||
if r == nil || cache == nil || cacheKey == "" {
|
if r == nil || cache == nil || cacheKey == "" {
|
||||||
log.Error().Msg("could not create CacheReader")
|
log.Error().Msg("could not create CacheReader")
|
||||||
return r
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &writeCacheReader{
|
return &writeCacheReader{
|
||||||
rc: r,
|
rc: r,
|
||||||
buff: bytes.NewBuffer(buf),
|
buff: bytes.NewBuffer(make([]byte, 0)),
|
||||||
f: &f,
|
f: &f,
|
||||||
cache: cache,
|
cache: cache,
|
||||||
cacheKey: cacheKey,
|
cacheKey: cacheKey,
|
||||||
|
|
Loading…
Reference in a new issue