divan/DivanRazor/APIRoot.cs
Anas Rashid 532d005cdb Rename Ganjoor -> Divan throughout the code
Projects (GanjooRazor -> DivanRazor, GanjoorService.sln -> DivanService.sln), files,
folders, classes, namespaces, settings, API routes (/api/divan) and DB tables (Divan*).
External addresses (ganjoor.net, github.com/ganjoor) unchanged. Migrations renamed
consistently (no pending model changes); requires a fresh database.
Upstream RUNNING_LOCALLY/SEMANTIC_SEARCH docs archived unmodified under docs/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 23:49:01 +02:00

75 lines
2.8 KiB
C#

using Microsoft.Extensions.Configuration;
using System.IO;
namespace DivanRazor
{
/// <summary>
/// API Root
/// </summary>
public static class APIRoot
{
/// <summary>
/// url
/// </summary>
public static string Url
{
get
{
if (!string.IsNullOrEmpty(_url))
return _url;
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").AddEnvironmentVariables() // divan: honour env overrides (Docker)
.Build();
_url = configuration["APIRoot"];
return _url;
}
}
private static string _url = "";
private static string _InternetUrl = "";
/// <summary>
/// internet accessible end point
/// </summary>
public static string InternetUrl
{
get
{
if (!string.IsNullOrEmpty(_InternetUrl))
return _InternetUrl;
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").AddEnvironmentVariables() // divan: honour env overrides (Docker)
.Build();
_InternetUrl = configuration["GlobalAPIRoot"];
return _InternetUrl;
}
}
private static string _semanticSearchUrl = "";
/// <summary>
/// Semantic search API endpoint — deliberately configurable separately from
/// Url/InternetUrl. Currently points at a physically separate domain/app pool
/// (ganjgah.ir) hosting the same RMuseum codebase, so that a problem with this one
/// feature (a native ONNX Runtime crash, a performance issue, anything) can't affect
/// api.ganjoor.net or the main site at all — proven necessary by an actual production
/// incident, not a hypothetical precaution. Point this at the main API root instead once
/// the feature has run stably on its own domain for a while.
/// </summary>
public static string SemanticSearchUrl
{
get
{
if (!string.IsNullOrEmpty(_semanticSearchUrl))
return _semanticSearchUrl;
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").AddEnvironmentVariables() // divan: honour env overrides (Docker)
.Build();
_semanticSearchUrl = configuration["SemanticSearchAPIRoot"];
return _semanticSearchUrl;
}
}
}
}