You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dart Frog supports creating a custom entrypoint in cases where you need fine-grained control over the server initialization or wish to execute code prior to starting the server.
8
+
9
+
## Creating a Custom Entrypoint ✨
10
+
11
+
To create a custom entrypoint, simply create a `main.dart` file at the root of your Dart Frog project. The `main.dart` file must expose a top-level `run` method with the following signature:
12
+
13
+
```dart
14
+
import 'dart:io';
15
+
16
+
import 'package:dart_frog/dart_frog.dart';
17
+
18
+
Future<HttpServer> run(Handler handler, InternetAddress ip, int port) {
19
+
// 1. Execute any custom code prior to starting the server...
20
+
21
+
// 2. Use the provided `handler`, `ip`, and `port` to create a custom `HttpServer`.
22
+
// Or use the Dart Frog serve method to do that for you.
23
+
return serve(handler, ip, port);
24
+
}
25
+
```
26
+
27
+
The Dart Frog CLI will detect the custom entrypoint and execute your custom `run` method instead of the default implementation.
0 commit comments