Implements native host process support with .NET backend: - Add .NET host project with HTTP endpoints (health check, hello world) - Configure multi-platform host executables in addon.json - Add host communication methods in main process - Create host demo tab in UI - Add .gitignore for .NET build artifacts The host process runs on a dynamic port and communicates via HTTP with the main addon process.
36 lines
992 B
C#
36 lines
992 B
C#
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Configure port from environment variable (set by GitCaddy AddonManager)
|
|
var port = Environment.GetEnvironmentVariable("ADDON_HOST_PORT") ?? "47933";
|
|
builder.WebHost.UseUrls($"http://127.0.0.1:{port}");
|
|
|
|
var app = builder.Build();
|
|
|
|
// Root endpoint
|
|
app.MapGet("/", () => new {
|
|
status = "ok",
|
|
service = "MyFirstAddon.Host",
|
|
version = "1.0.0"
|
|
});
|
|
|
|
// Health check endpoint (required by GitCaddy)
|
|
app.MapGet("/health", () => new {
|
|
status = "healthy",
|
|
timestamp = DateTime.UtcNow
|
|
});
|
|
|
|
// Hello World endpoint - demonstrates a simple addon host function
|
|
app.MapGet("/hello", () => new {
|
|
message = "Hello World from MyFirstAddon.Host!",
|
|
timestamp = DateTime.UtcNow
|
|
});
|
|
|
|
// Hello endpoint with name parameter
|
|
app.MapGet("/hello/{name}", (string name) => new {
|
|
message = $"Hello, {name}!",
|
|
timestamp = DateTime.UtcNow
|
|
});
|
|
|
|
Console.WriteLine($"MyFirstAddon.Host starting on http://127.0.0.1:{port}");
|
|
app.Run();
|