Lahat ng language at framework
FastEndpoints C#
Isang C# snippet para sa FastEndpoints na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.
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);
}
}
Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.
Suriin
curl -sI http://localhost:8080/pixel.gif
Opisyal na site: FastEndpoints