FastEndpoints C#
FastEndpoints के लिए C# स्निपेट, जो /pixel.gif पर आने वाली रिक्वेस्ट का जवाब empty GIF से देता है। GIF स्टार्टअप पर एक ही बार डिकोड होता है।
FastEndpoints C#
using FastEndpoints;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddFastEndpoints();
var app = builder.Build();
app.UseFastEndpoints();
app.Run("http://0.0.0.0:8080");
sealed class PixelEndpoint : EndpointWithoutRequest
{
static readonly byte[] Gif = Convert.FromBase64String("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");
public override void Configure()
{
Get("/pixel.gif");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
HttpContext.Response.Headers.CacheControl = "no-store";
await Send.BytesAsync(Gif, contentType: "image/gif", cancellation: ct);
}
}
हमने यह स्निपेट चलाया और इसके लौटाए बाइट्स की तुलना की।
जाँचें
curl -sI http://localhost:8080/pixel.gif