From 1017d0a80a9f3dfa3233c9c73bda7462881d0849 Mon Sep 17 00:00:00 2001 From: Yorick de Wid Date: Mon, 21 Oct 2024 14:06:48 +0200 Subject: [PATCH] Refactor TileController to remove unused code and improve performance --- .../Controllers/TileController.cs | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 src/FunderMaps.WebApi/Controllers/TileController.cs diff --git a/src/FunderMaps.WebApi/Controllers/TileController.cs b/src/FunderMaps.WebApi/Controllers/TileController.cs deleted file mode 100644 index 38804ac8..00000000 --- a/src/FunderMaps.WebApi/Controllers/TileController.cs +++ /dev/null @@ -1,40 +0,0 @@ -using FunderMaps.Core.Controllers; -using FunderMaps.Core.Interfaces.Repositories; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace FunderMaps.WebApi.Controllers; - -/// -/// Represents a controller for handling tile requests. -/// -[AllowAnonymous] -public class TileController(ITilesetRepository tilesetRepository) : FunderMapsController -{ - /// - /// Retrieves the specified tile data. - /// - /// The name of the tile. - /// The zoom level of the tile. - /// The x-coordinate of the tile. - /// The y-coordinate of the tile. - /// The tile data as a file. - [HttpGet("api/tile/{name}/{z}/{x}/{y}.vector.pbf")] - [ResponseCache(Duration = 60 * 60 * 24, VaryByHeader = "Authorization", Location = ResponseCacheLocation.Client)] - public async Task GetAsync(string name, int z, int x, int y) - { - var fileContent = await tilesetRepository.GetTileAsync(name, z, x, y); - if (fileContent == null || fileContent.Length < 2) - { - return NotFound(); - } - - // Check if the file is gzipped. - if (fileContent[0] == 0x1F && fileContent[1] == 0x8B) - { - Response.Headers.Append("Content-Encoding", "gzip"); - } - - return File(fileContent, "application/x-protobuf"); - } -}