mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-05 14:07:01 +00:00
format code
This commit is contained in:
parent
ba00db990b
commit
cf78f5fda2
1 changed files with 13 additions and 16 deletions
|
@ -151,25 +151,22 @@ func (client *Client) ServeRawContent(targetOwner, targetRepo, ref, resource str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we are sure it's content
|
// now we are sure it's content so set the MIME type
|
||||||
{
|
mimeType := client.getMimeTypeByExtension(resource)
|
||||||
// Set the MIME type
|
resp.Response.Header.Set(ContentTypeHeader, mimeType)
|
||||||
mimeType := client.getMimeTypeByExtension(resource)
|
|
||||||
resp.Response.Header.Set(ContentTypeHeader, mimeType)
|
|
||||||
|
|
||||||
if !shouldRespBeSavedToCache(resp.Response) {
|
if !shouldRespBeSavedToCache(resp.Response) {
|
||||||
return reader, resp.Response.Header, resp.StatusCode, err
|
return reader, resp.Response.Header, resp.StatusCode, err
|
||||||
}
|
|
||||||
|
|
||||||
// now we write to cache and respond at the sime time
|
|
||||||
fileResp := FileResponse{
|
|
||||||
Exists: true,
|
|
||||||
ETag: resp.Header.Get(ETagHeader),
|
|
||||||
MimeType: mimeType,
|
|
||||||
}
|
|
||||||
return fileResp.CreateCacheReader(reader, client.responseCache, cacheKey), resp.Response.Header, resp.StatusCode, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now we write to cache and respond at the sime time
|
||||||
|
fileResp := FileResponse{
|
||||||
|
Exists: true,
|
||||||
|
ETag: resp.Header.Get(ETagHeader),
|
||||||
|
MimeType: mimeType,
|
||||||
|
}
|
||||||
|
return fileResp.CreateCacheReader(reader, client.responseCache, cacheKey), resp.Response.Header, resp.StatusCode, nil
|
||||||
|
|
||||||
case http.StatusNotFound:
|
case http.StatusNotFound:
|
||||||
if err := client.responseCache.Set(cacheKey, FileResponse{
|
if err := client.responseCache.Set(cacheKey, FileResponse{
|
||||||
Exists: false,
|
Exists: false,
|
||||||
|
|
Loading…
Reference in a new issue