emptygif
Langue: Français

Tous les langages et frameworks

Falco F#

Un extrait F# pour Falco qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

Falco F#

Installer
dotnet add package Falco
Fichier
Program.fs
Lancer
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")

Nous avons exécuté cet extrait et comparé les octets qu’il a renvoyés.

Vérifier

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

Site officiel: Falco

Autres extraits en F#