veb (V web framework) V
適用於 veb (V web framework) 的 V 程式碼片段,以空 GIF 回應對 /pixel.gif 的請求,GIF 在啟動時只解碼一次。
veb (V web framework) 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)
}
已對照該框架目前的文件確認。
驗證
curl -sI http://localhost:8080/pixel.gif