emptygif
Langue: Français

Tous les langages et frameworks

veb (V web framework) V

Un extrait V pour veb (V web framework) qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

veb (V web framework) V

Fichier
server.v
Lancer
v run server.v
module main

import encoding.base64
import veb

const gif = base64.decode_str('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==')

pub struct Context {
    veb.Context
}

pub struct App {}

@['/pixel.gif'; get]
pub fn (app &App) pixel(mut ctx Context) veb.Result {
    ctx.set_header(.cache_control, 'no-store')
    return ctx.send_response_to_client('image/gif', gif)
}

fn main() {
    mut app := &App{}
    veb.run[App, Context](mut app, 8080)
}

Vérifié par rapport à la documentation actuelle du framework.

Vérifier

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

Site officiel: veb (V web framework)