Rack Ruby
Snippet na Ruby don Rack da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.
Rack Ruby
GIF = "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==".unpack1("m0").freeze
HEADERS = {
"content-type" => "image/gif",
"content-length" => GIF.bytesize.to_s,
"cache-control" => "no-store",
}.freeze
run lambda { |env|
if env["REQUEST_METHOD"] == "GET" && env["PATH_INFO"] == "/pixel.gif"
[200, HEADERS.dup, [GIF]]
else
[404, { "content-type" => "text/plain" }, ["Not Found"]]
end
}
Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.
Duba shi
curl -sI http://localhost:8080/pixel.gif