Removed Immediate.Apis, Added AOT Testing Scripts.

This commit is contained in:
2026-05-05 18:47:11 +05:00
parent ec7ab8aadc
commit 22577fe3fb
27 changed files with 623 additions and 422 deletions
+23
View File
@@ -0,0 +1,23 @@
namespace Htmx.ApiDemo;
public static class HtmxExtensions
{
public static void HtmxAwareWriteToBody(
this IHtmxComponent component, HttpContext context, string title, string appName, string pageTitle)
{
// If not a HX-Request, render the component inside main layout
if (!context.Request.Headers.ContainsKey("HX-Request"))
{
var layout = new MainLayout(component, title: title, appName: appName, pageTitle: pageTitle,
userName: context.User.Identity?.IsAuthenticated == true ? context.User.Identity.Name : null);
context.Response.ContentType = "text/html; charset=utf-8";
var renderContext = new HtmxRenderContext(context.Response.BodyWriter);
layout.Render(renderContext);
return;
}
//Else only render the component
component.WriteToResponseBody(context);
}
}
+24
View File
@@ -0,0 +1,24 @@
using Htmx.ApiDemo.Data;
namespace Htmx.ApiDemo;
public static partial class RouteMap
{
public static void MapHtmxRoutes(this WebApplication app)
{
MapGetIndex(app);
GetRegister(app);
PostRegister(app);
PostLogout(app);
GetLogin(app);
PostLogin(app);
GetUiDemo(app);
}
private static void PostLogout(WebApplication app)
=> app.MapPost("/logout", async (HttpContext context, AppAuthService authService) =>
{
await authService.SignOutAsync();
return Results.Redirect("/login");
});
}