Kemal Crystal
/pixel.gif 요청에 빈 GIF로 응답하는 Kemal용 Crystal 스니펫입니다. 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