using System; using System.IO; using System.Reflection; using Gott.Services; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; namespace Gott.Endpoints; public static class InfoEndpoint { public static void MapInfoEndpoint(this IEndpointRouteBuilder app) { app.MapGet("/api/info", HandleInfo); } private static IResult HandleInfo(EmbeddingService embeddingService) { var assembly = Assembly.GetExecutingAssembly(); var location = assembly.Location; long buildTime = 0; if (!string.IsNullOrEmpty(location) && File.Exists(location)) { var lastWrite = File.GetLastWriteTimeUtc(location); buildTime = new DateTimeOffset(lastWrite).ToUnixTimeSeconds(); } else { var dir = AppContext.BaseDirectory; var exeName = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows) ? "gott.exe" : "gott"; var exePath = Path.Combine(dir, exeName); if (File.Exists(exePath)) { var lastWrite = File.GetLastWriteTimeUtc(exePath); buildTime = new DateTimeOffset(lastWrite).ToUnixTimeSeconds(); } } var isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows); var embeddingAvailable = embeddingService.IsAvailable; return Results.Json(new { buildTime, isWindows, embeddingAvailable }); } }