emptygif
Language: English

All languages and frameworks

Quarkus Java

A Java snippet for Quarkus that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Quarkus Java

Install
quarkus create app org.acme:pixel --extension=rest
File
PixelResource.java
Run
quarkus dev
package org.acme;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Response;
import java.util.Base64;

@Path("/pixel.gif")
public class PixelResource {

    private static final byte[] GIF = Base64.getDecoder().decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==");

    @GET
    @Produces("image/gif")
    public Response pixel() {
        return Response.ok(GIF).header("Cache-Control", "no-store").build();
    }
}

We ran this snippet and compared the bytes it returned.

Check it

curl -sI http://localhost:8080/pixel.gif

Official site: Quarkus

More in Java