relic_headers 패키지는 Relic 어댑터 및 관련 패키지에서 사용되는 표준화된 HTTP 헤더 이름과 저장 유틸리티의 모음을 제공합니다. 헤더 처리의 일관성을 보장하여 오류를 줄이고 HTTP 클라이언트와 서버 간의 상호 운용성을 향상시킵니다. 자주 사용되는 헤더를 중앙 집중화함으로써 네트워크 통신 워크플로우에서 구성 및 유지보수를 단순화합니다. ServerPod 생태계 내에서 사용하도록 설계되었으며, HTTP 상호작용을 위한 깔끔하고 재사용 가능한 코드를 지원합니다.
사용 사례
서비스 간 HTTP 헤더 사용 표준화
HTTP 클라이언트에서 헤더 관리 간소화
일관된 API 통신 활성화
리릭 어댑터 통합 지원
백엔드 간 요청 조정을 촉진
주요 기능
중앙 집중형 HTTP 헤더 정의
헤더 값에 대한 공유 저장소
어댑터 간 일관된 이름 지정
경량이며 종속성 중심
ServerPod 생태계를 위한 설계
적합한 대상
ServerPod 또는 Relic 어댑터를 사용하는 개발자
일관된 HTTP 헤더 처리가 필요한 팀
신뢰할 수 있는 HTTP 클라이언트 구성이 필요한 프로젝트
백엔드 서비스 통신
일관된 헤더를 갖춘 API 통합
고려 사항
주로 ServerPod 프로젝트 내에서 사용하기 위해 설계되었습니다
에코시스템 외부에서의 독립적인 유틸리티는 제한적
비-Relic 워크플로우에 대한 추가 설정이 필요할 수 있습니다
컨텍스트 없이 일반 목적의 HTTP 라이브러리에 적합하지 않음
원본 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.