emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Giraffe F#

Giraffe için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir F# örneği.

Giraffe F#

Kurulum
dotnet add package Giraffe
Dosya
Program.fs
Çalıştır
dotnet run
open System
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.DependencyInjection
open Giraffe

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

let pixel: HttpHandler =
    setHttpHeader "Content-Type" "image/gif"
    >=> setHttpHeader "Cache-Control" "no-store"
    >=> setBody gif

let webApp =
    choose [
        GET >=> route "/pixel.gif" >=> pixel
        RequestErrors.NOT_FOUND "Not Found"
    ]

let builder = WebApplication.CreateBuilder()
builder.Services.AddGiraffe() |> ignore

let app = builder.Build()
app.UseGiraffe webApp
app.Run "http://0.0.0.0:8080"

Bu örneği çalıştırıp döndürdüğü baytları karşılaştırdık.

Kontrol et

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

Resmî site: Giraffe

F# için daha fazlası