அனைத்து மொழிகளும் ஃப்ரேம்வொர்க்குகளும்
FastEndpoints C#
/pixel.gif க்கு வரும் ரெக்வெஸ்ட்களுக்கு empty GIF மூலம் பதிலளிக்கும், FastEndpoints க்கான C# ஸ்னிப்பெட். 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
அதிகாரப்பூர்வ சைட்: FastEndpoints