emptygif
言語: 日本語

すべての言語・フレームワーク

Dart Frog Dart

/pixel.gif へのリクエストに空の GIF を返す、Dart Frog 用の Dart スニペット。GIF は起動時に一度だけデコードします。

Dart Frog Dart

インストール
dart pub global activate dart_frog_cli
ファイル
pixel.gif.dart
実行
dart_frog dev
// routes/pixel.gif.dart: the file name is the route.
import 'dart:convert';

import 'package:dart_frog/dart_frog.dart';

final _gif = base64Decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

Response onRequest(RequestContext context) {
  return Response.bytes(
    body: _gif,
    headers: {'content-type': 'image/gif', 'cache-control': 'no-store'},
  );
}

このスニペットは実行し、返されたバイト列を照合しました。

確認

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

公式サイト: Dart Frog

Dart の他の例