Oxpecker F#
/pixel.gif 요청에 빈 GIF로 응답하는 Oxpecker용 F# 스니펫입니다. GIF는 시작할 때 한 번만 디코딩합니다.
Oxpecker F#
open System
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.DependencyInjection
open Oxpecker
let gif = Convert.FromBase64String "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
let pixel: EndpointHandler =
setHttpHeader "Content-Type" "image/gif"
>=> setHttpHeader "Cache-Control" "no-store"
>=> bytes gif
let endpoints = [ GET [ route "/pixel.gif" pixel ] ]
let builder = WebApplication.CreateBuilder()
builder.Services.AddRouting().AddOxpecker() |> ignore
let app = builder.Build()
app.UseRouting().UseOxpecker(endpoints) |> ignore
app.Run "http://0.0.0.0:8080"
이 스니펫은 실행해 보고, 반환된 바이트를 비교했습니다.
확인
curl -sI http://localhost:8080/pixel.gif