emptygif
언어: 한국어

모든 언어 및 프레임워크

Roda Ruby

/pixel.gif 요청에 빈 GIF로 응답하는 Roda용 Ruby 스니펫입니다. GIF는 시작할 때 한 번만 디코딩합니다.

Roda Ruby

설치
gem install roda rackup puma
파일
config.ru
실행
rackup -p 8080
require "roda"

class App < Roda
  GIF = "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==".unpack1("m0").freeze

  route do |r|
    # Roda string matchers are written without the leading slash.
    r.get "/pixel.gif".delete_prefix("/") do
      response["content-type"] = "image/gif"
      response["cache-control"] = "no-store"
      GIF
    end
  end
end

run App.freeze.app

이 스니펫은 실행해 보고, 반환된 바이트를 비교했습니다.

확인

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

공식 사이트: Roda

Ruby의 다른 예제