GCR deployment testing in progress - content type issue still remaining.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Immediate.Apis.Shared;
|
||||
using Immediate.Handlers.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Htmx.ApiDemo.Templates;
|
||||
|
||||
@@ -21,9 +23,14 @@ public sealed class Greeting : GreetingBase
|
||||
[MapGet("/greet/{username}/{count?}/{id?}")]
|
||||
public static partial class GetGreetingHandler
|
||||
{
|
||||
public record Query(string Username, int? Count, Guid? Id);
|
||||
public class Query
|
||||
{
|
||||
[FromRoute] public string Username { get; set; } = default!;
|
||||
[FromRoute] public string? Count { get; set; }
|
||||
[FromRoute] public string? Id { get; set; }
|
||||
}
|
||||
|
||||
private static ValueTask HandleAsync(
|
||||
private static ValueTask<IResult> HandleAsync(
|
||||
Query query,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
CancellationToken token)
|
||||
@@ -31,8 +38,9 @@ public static partial class GetGreetingHandler
|
||||
var context = httpContextAccessor.HttpContext
|
||||
?? throw new InvalidOperationException("HttpContext is not available.");
|
||||
|
||||
var template = new Greeting { Username = query.Username, Count = query.Count + 1 ?? 0, GreetingId = query.Id ?? Guid.NewGuid() };
|
||||
context.WriteHtmxBody(template);
|
||||
return ValueTask.CompletedTask;
|
||||
var count = int.TryParse(query.Count, out var parsedCount) ? parsedCount + 1 : 0;
|
||||
var greetingId = Guid.TryParse(query.Id, out var parsedId) ? parsedId : Guid.NewGuid();
|
||||
var template = new Greeting { Username = query.Username, Count = count, GreetingId = greetingId };
|
||||
return ValueTask.FromResult<IResult>(context.WriteHtmxBody(template));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user