Kemal Crystal
適用於 Kemal 的 Crystal 程式碼片段,以空 GIF 回應對 /pixel.gif 的請求,GIF 在啟動時只解碼一次。
Kemal Crystal
require "base64"
require "kemal"
GIF = Base64.decode("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")
get "/pixel.gif" do |env|
env.response.content_type = "image/gif"
env.response.headers["Cache-Control"] = "no-store"
env.response.write(GIF) # write the bytes; a non-String return value is ignored
nil
end
Kemal.run(8080)
已對照該框架目前的文件確認。
驗證
curl -sI http://localhost:8080/pixel.gif