emptygif
Language: English

All languages and frameworks

Oxpecker F#

A F# snippet for Oxpecker that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Oxpecker F#

Install
dotnet add package Oxpecker
File
Program.fs
Run
dotnet run
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"

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Oxpecker

More in F#