Skip to content

Commit

Permalink
fix(lambda-tiler): Return 204 non content for empty 404 vector tile. (#…
Browse files Browse the repository at this point in the history
…2391)

* Return 204 non content for empty vector tile.

* move the no content response into util

* Fix the naming
  • Loading branch information
Wentao-Kuang authored Jul 31, 2022
1 parent e94b613 commit 0d4373e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/lambda-tiler/src/routes/tile.xyz.vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GoogleTms, VectorFormat } from '@basemaps/geo';
import { HttpHeader, LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
import { isGzip } from '../util/cotar.serve.js';
import { Etag } from '../util/etag.js';
import { NotFound, NotModified } from '../util/response.js';
import { NoContent, NotFound, NotModified } from '../util/response.js';
import { CoSources } from '../util/source.cache.js';
import { TileXyz } from '../util/validate.js';

Expand Down Expand Up @@ -34,7 +34,7 @@ export const tileXyzVector = {

req.timer.start('cotar:tile');
const tile = await cotar.get(tilePath);
if (tile == null) return NotFound();
if (tile == null) return NoContent();
req.timer.end('cotar:tile');

const tileBuffer = Buffer.from(tile);
Expand Down
1 change: 1 addition & 0 deletions packages/lambda-tiler/src/util/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import { LambdaHttpResponse } from '@linzjs/lambda';

export const NotFound = (): LambdaHttpResponse => new LambdaHttpResponse(404, 'Not Found');
export const NotModified = (): LambdaHttpResponse => new LambdaHttpResponse(304, 'Not modified');
export const NoContent = (): LambdaHttpResponse => new LambdaHttpResponse(204, 'No Content');

0 comments on commit 0d4373e

Please sign in to comment.