Movatterモバイル変換


[0]ホーム

URL:


relic_core 1.0.0copy "relic_core: ^1.0.0" to clipboard
relic_core: ^1.0.0 copied to clipboard

Metadata

Core framework for Relic web server (platform-agnostic).

More...

Relic web server banner

buildcodecovStars on GithubLicense: BSD-3-Clause

Relic web server#

Relic is a modern, high-performance web server framework inspired byShelf and built by theServerpod 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 withdart --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_worldcd hello_worlddart pub add relic

Run your first Relic server#

Place this file inbin/hello_world.dart (runnable example is also underexample/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 withdart run bin/hello_world.dart and visithttp://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 theexample directory.

git clone https://github.com/serverpod/relic.gitcd relic/exampledart 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 atdocs.dartrelic.dev/getting-started/shelf-migration to upgrade your project in minutes.

1
likes
160
points
17.8k
downloads

Publisher

verified publisherserverpod.dev

Weekly Downloads

Metadata

Core framework for Relic web server (platform-agnostic).

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#server#web#backend#http

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

async,collection,convert,crypto,http_parser,meta,mime,path,stack_trace,stream_channel,vm_service,web_socket,web_socket_channel

More

Packages that depend on relic_core

Metadata

1
likes
160
points
17.8k
downloads

Publisher

verified publisherserverpod.dev

Weekly Downloads

Metadata

Core framework for Relic web server (platform-agnostic).

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#server#web#backend#http

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

async,collection,convert,crypto,http_parser,meta,mime,path,stack_trace,stream_channel,vm_service,web_socket,web_socket_channel

More

Packages that depend on relic_core

Back


[8]ページ先頭

©2009-2026 Movatter.jp