| | | 1 | | using Anichron.API.Infrastructure; |
| | | 2 | | using Anichron.Core.Domain; |
| | | 3 | | |
| | | 4 | | namespace Anichron.API.Endpoints; |
| | | 5 | | |
| | | 6 | | internal sealed record ProxyKind(ProxyType Type, string Slug, string ContentType); |
| | | 7 | | |
| | | 8 | | internal static class ProxyKinds |
| | | 9 | | { |
| | 190 | 10 | | internal static IReadOnlyList<ProxyKind> All => Table(); |
| | | 11 | | |
| | | 12 | | internal static ProxyKind? FromSlug(string slug) |
| | 29 | 13 | | => All.FirstOrDefault(kind => kind.Slug == slug); |
| | | 14 | | |
| | | 15 | | internal static string UrlOf(Guid assetId, ProxyType type, string contentHash) |
| | 28 | 16 | | => ApiPaths.Proxies.ProxyUrl(assetId, All.Single(kind => kind.Type == type).Slug, contentHash); |
| | | 17 | | |
| | | 18 | | private static ProxyKind[] Table() |
| | 190 | 19 | | { |
| | 190 | 20 | | return |
| | 190 | 21 | | [ |
| | 190 | 22 | | new(ProxyType.Thumbnail, "thumbnail", "image/jpeg"), |
| | 190 | 23 | | new(ProxyType.FullPreview, "preview", "image/jpeg"), |
| | 190 | 24 | | new(ProxyType.CompactPreview, "compact-preview", "image/jxl"), |
| | 190 | 25 | | new(ProxyType.WebVideo, "video", "video/mp4"), |
| | 190 | 26 | | ]; |
| | 190 | 27 | | } |
| | | 28 | | } |