원클릭으로
relic-app-setup
// Bootstrap a Relic web server, configure RelicApp, start serving, and enable hot reload. Use when creating a new Relic project, setting up a server, or configuring the development workflow.
// Bootstrap a Relic web server, configure RelicApp, start serving, and enable hot reload. Use when creating a new Relic project, setting up a server, or configuring the development workflow.
| name | relic-app-setup |
| description | Bootstrap a Relic web server, configure RelicApp, start serving, and enable hot reload. Use when creating a new Relic project, setting up a server, or configuring the development workflow. |
Relic is a Dart web server framework. Requires Dart SDK 3.7+. Single import: package:relic/relic.dart.
dart create -t console-full my_server
cd my_server
dart pub add relic
import 'package:relic/relic.dart';
Future<void> main() async {
final app = RelicApp()
..get('/hello/:name', (Request req) {
final name = req.rawPathParameters[#name];
return Response.ok(
body: Body.fromString('Hello, $name!'),
);
})
..use('/', logRequests())
..fallback = respondWith(
(_) => Response.notFound(
body: Body.fromString('Not found'),
),
);
await app.serve();
}
await app.serve(); // defaults to 0.0.0.0:8080
await app.serve(
address: InternetAddress.loopbackIPv4,
port: 3000,
);
The fallback handles requests that don't match any route. Default is 404 with an empty body.
app.fallback = respondWith(
(_) => Response.notFound(
body: Body.fromString('Page not found'),
),
);
Relic supports hot reload of route handlers without server restart.
IDE: Start the server in Debug mode. Enable "Hot Reload On Save" in your Dart plugin settings (typically set it to manual).
CLI:
dart run --enable-vm-service bin/main.dart
When a hot reload is triggered, RelicApp automatically reconfigures its internal router with the latest route definitions. Changes to server state or global variables may still require a full restart.
Create and apply middleware for auth, CORS, logging, and other cross-cutting concerns. Use context properties for type-safe request-scoped data. Use when adding middleware, request/response transformations, or passing data between middleware and handlers.
Handle HTTP requests and create responses with Body, headers, and status codes in Relic. Use when reading request data, parsing JSON, building API responses, working with headers, or streaming content.
Define routes with path parameters, wildcards, tail segments, and typed params in Relic. Use when adding endpoints, handling dynamic URLs, setting up URL patterns, or forwarding requests.
Migrate a Dart web server from Shelf to Relic. Side-by-side reference for every API change. Use when converting Shelf code to Relic, replacing shelf/shelf_router/shelf_web_socket imports, or upgrading an existing server.
Serve static files and directories with caching and cache busting in Relic. Use when serving assets, images, CSS, JS, favicons, or configuring HTTP cache control headers.
Handle WebSocket connections and hijack connections for SSE or custom protocols in Relic. Use when implementing real-time communication, WebSocket endpoints, or server-sent events.