mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 02:41:09 +00:00
pass HTTP metadata in S3/R2 Source impls
This commit is contained in:
@@ -866,6 +866,8 @@ export class PMTiles {
|
||||
d_l = entry.length;
|
||||
}
|
||||
} else {
|
||||
// TODO: We should in fact return a valid RangeResponse
|
||||
// with empty data, but filled in cache control / expires headers
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,12 @@ class S3Source implements Source {
|
||||
|
||||
const arr = await resp.Body!.transformToByteArray();
|
||||
|
||||
return { data: arr.buffer };
|
||||
return {
|
||||
data: arr.buffer,
|
||||
etag: resp.ETag,
|
||||
expires: resp.Expires?.toISOString(),
|
||||
cacheControl: resp.CacheControl,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +161,7 @@ export const handler = async (
|
||||
// TODO: metadata and TileJSON
|
||||
|
||||
if (process.env.CORS) {
|
||||
headers['Access-Control-Allow-Origin'] = process.env.CORS;
|
||||
headers["Access-Control-Allow-Origin"] = process.env.CORS;
|
||||
}
|
||||
|
||||
const source = new S3Source(name);
|
||||
|
||||
@@ -109,7 +109,12 @@ class R2Source implements Source {
|
||||
}
|
||||
const o = resp as R2ObjectBody;
|
||||
const a = await o.arrayBuffer();
|
||||
return { data: a, etag: o.etag };
|
||||
return {
|
||||
data: a,
|
||||
etag: o.etag,
|
||||
cacheControl: o.httpMetadata?.cacheControl,
|
||||
expires: o.httpMetadata?.cacheExpiry?.toISOString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user