パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.0

relic

Shelf を参考にした、API やバックエンドサービスの構築に適した軽量で柔軟なウェブサーバー。

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
22.8万
いいね数
119
Pub ポイント
160

パッケージをインストール

flutter pub add relic

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Relic は、Shelf を参考にした軽量で柔軟な Dart 用 Web サーバーであり、API およびバックエンドサービスの構築を目的としています。HTTP リクエストとレスポンスを扱うためのシンプルでモジュール式のアプローチを提供し、複数のプラットフォームでパフォーマンスと使いやすさを追求する開発者にとって理想的です。Android、iOS、macOS、Windows、Linux をサポートしており、Flutter アプリケーション内や独立したサービスにおいてもシームレスなバックエンド開発が可能です。最小限のリソース消費と洗練された API により、迅速なプロトタイピングとスケーラブルなデプロイメントが実現します。

用途

  • RESTful API の構築
  • Flutterアプリ用のバックエンドサービスの作成
  • クロスプラットフォームのサーバーサイドロジックの開発
  • マイクロサービスのプロトタイピング
  • HTTPリクエストルーティングの処理

主な機能

  • 軽量で高速
  • モジュール型ミドルウェアサポート
  • クロスプラットフォーム互換性
  • シンプルで直感的な API
  • 組み込みのリクエスト/レスポンス処理

適している対象

  • バックエンド機能が必要なFlutter開発者
  • マイクロサービスを構築するチーム
  • ソロ開発者がAPIをプロトタイプ化する
  • 複数のプラットフォームでサーバーサイドロジックを必要とするプロジェクト
  • 低遅延要件を備えたアプリケーション

注意事項

  • 追加のスケーリングなしでは、高並行な生産ワークロードには適していません
  • 完全なフレームワークと比較して、組み込み認証機能が限られている
  • データベース統合には手動設定が必要です
  • 小規模から中規模のアプリケーションに最適
  • コアパッケージに組み込みの WebSocket サポートなし

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Relic web server banner

build codecov Stars on Github License: BSD-3-Clause

Relic web server

Relic is a modern, high-performance web server framework inspired by Shelf and built by the Serverpod team to meet the demanding requirements of modern web applications. Relic provides a robust, type-safe, and efficient foundation for building scalable web services.

👉 Full documentation available here 📚

Why Relic?

While Shelf has been a solid foundation for Dart web applications, several areas for improvement were identified. Rather than work around these limitations, Relic was created as a next-generation framework that maintains Shelf's familiar structure while delivering significant enhancements. These are some of the improvements:

  • Strongly typed APIs with validated HTTP headers.
  • Simplified interface for setting up routing and middleware.
  • Unified encoding model for HTTP bodies.
  • Built-in trie-based router, which improves performance.
  • Static file handling with support for cache busting and etags.
  • Built-in support for WebSockets.
  • Improvements in hot reload and running with multiple isolates.

Quick start

  1. Install Dart 3.7 or newer and verify with dart --version.
  2. Add Relic: dart pub add relic
  3. Create a new console app and drop in the hello world server below.
dart create -t console-full hello_world
cd hello_world
dart pub add relic
Run your first Relic server

Place this file in bin/hello_world.dart (runnable example is also under example/example.dart):

import 'package:relic/io_adapter.dart';
import 'package:relic/relic.dart';

/// A simple 'Hello World' server demonstrating basic Relic usage.
Future<void> main() async {
  // Setup the app.
  final app =
      RelicApp()
        // Route with parameters (:name & :age).
        ..get('/user/:name/age/:age', helloHandler)
        // Middleware on all paths below '/'.
        ..use('/', logRequests())
        // Custom fallback - optional (default is 404 Not Found).
        ..fallback = respondWith(
          (_) => Response.notFound(
            body: Body.fromString("Sorry, that doesn't compute.\n"),
          ),
        );

  // Start the server (defaults to using port 8080).
  await app.serve();
}

const _ageParam = PathParam<int>(#age, int.parse);
/// Handles requests to the hello endpoint with path parameters.
Response helloHandler(final Request req) {
  final name = req.pathParameters.raw[#name];
  final age = req.pathParameters.get(_ageParam);

  return Response.ok(
    body: Body.fromString('Hello, $name! To think you are $age years old.\n'),
  );
}

Run it with dart run bin/hello_world.dart and visit http://localhost:8080/user/Nova/age/27.

Additional examples

Relic comes with an extensive set of examples. To run them, clone the Relic repository from GitHub and navigate to the example directory.

git clone https://github.com/serverpod/relic.git
cd relic/example
dart example.dart

Migrating from Shelf

Are you on Shelf? Moving over is straightforward. Relic's APIs are very similar while giving you typed requests, built-in routing, and WebSockets out of the box. Follow the step-by-step guide at docs.dartrelic.dev/getting-started/shelf-migration to upgrade your project in minutes.

カテゴリー

依存関係

依存関係一覧 2 件

  • relic_core^2.0.0
  • relic_io^2.0.0

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。