emptygif
Language: English

All languages and frameworks

Falco F#

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

Falco F#

Install
dotnet add package Falco
File
Program.fs
Run
dotnet run
open System
open Falco
open Falco.Routing
open Microsoft.AspNetCore.Builder

let gif = Convert.FromBase64String "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="

let pixel: HttpHandler =
    Response.ofBinary "image/gif" [ "Cache-Control", "no-store" ] gif

let endpoints = [ get "/pixel.gif" pixel ]

let wapp = WebApplication.Create()
wapp.Urls.Add "http://0.0.0.0:8080"

wapp.UseRouting()
    .UseFalco(endpoints)
    .Run(Response.withStatusCode 404 >> Response.ofPlainText "Not Found")

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Falco

More in F#