Relic은 Shelf를 영감으로 삼아 만든 가볍고 유연한 Dart용 웹 서버로, API 및 백엔드 서비스 구축을 위해 설계되었습니다. HTTP 요청과 응답을 처리하는 간단하고 모듈식 접근 방식을 제공하여 다양한 플랫폼에서 성능과 사용 편의성을 추구하는 개발자에게 이상적입니다. Android, iOS, macOS, Windows, Linux를 지원하며, Flutter 애플리케이션 또는 독립형 서비스 내에서 원활한 백엔드 개발을 가능하게 합니다. 최소한의 크기와 깔끔한 API는 빠른 프로토타이핑과 확장 가능한 배포를 가능하게 합니다.
사용 사례
RESTful API 구축
Flutter 앱용 백엔드 서비스 만들기
크로스 플랫폼 서버사이드 로직 개발
마이크로서비스 프로토타이핑
HTTP 요청 라우팅 처리
주요 기능
경량이고 빠름
모듈러 중간층 지원
크로스 플랫폼 호환성
간단하고 직관적인 API
내장된 요청/응답 처리
적합한 대상
백엔드 기능이 필요한 플러터 개발자
마이크로서비스를 구축하는 팀
솔로 개발자들이 API 프로토타이핑
다중 플랫폼에서 서버 측 로직이 필요한 프로젝트
저지연 요구 사항을 가진 응용 프로그램
고려 사항
추가 확장 없이 고병렬 생산 작업 부하에 적합하지 않습니다
완전한 프레임워크에 비해 내장 인증 기능이 제한적
데이터베이스 통합을 위해 수동 설정이 필요합니다
소규모에서 중규모 애플리케이션에 가장 적합
핵심 패키지에 내장된 WebSocket 지원 없음
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
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.
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
Install Dart 3.7 or newer and verify with dart --version.
Add Relic: dart pub add relic
Create a new console app and drop in the hello world server below.
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.ResponsehelloHandler(finalRequest req) {
final name = req.pathParameters.raw[#name];
final age = req.pathParameters.get(_ageParam);
returnResponse.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.