move / check into separat feature ("root")
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cinema/feature/poster/poster.service.dart';
|
||||
import 'package:cinema/feature/root/root.service.dart';
|
||||
import 'package:cinema/feature/version/version.dart';
|
||||
import 'package:cinema/feature/websocket/websocket.service.dart';
|
||||
import 'package:cinema/injectable.dart';
|
||||
import 'package:shelf/shelf.dart';
|
||||
import 'package:shelf/shelf_io.dart' as io;
|
||||
@@ -16,23 +15,17 @@ void main(List<String> args) async {
|
||||
|
||||
final router = Router();
|
||||
router.mount("/poster", getIt<PosterService>().router.call);
|
||||
router.mount("/", getIt<RootService>().router.call);
|
||||
|
||||
// Configure a pipeline that logs requests.
|
||||
final handler = Pipeline().addMiddleware(logRequests()).addHandler(router.call);
|
||||
|
||||
FutureOr<Response> combinedHandler(Request request) {
|
||||
if (request.url.path == 'ws') {
|
||||
return getIt<WebSocketService>().handler(request);
|
||||
}
|
||||
return handler(request);
|
||||
}
|
||||
|
||||
// Use any available host or container IP (usually `0.0.0.0`).
|
||||
final ip = InternetAddress.anyIPv4;
|
||||
|
||||
// For running in containers, we respect the PORT environment variable.
|
||||
final port = int.parse(Platform.environment['PORT'] ?? '3000');
|
||||
await io.serve(combinedHandler, ip, port, poweredByHeader: null).then((server) async {
|
||||
await io.serve(handler, ip, port, poweredByHeader: null).then((server) async {
|
||||
final bannerFile = File('banner.txt');
|
||||
if (await bannerFile.exists()) {
|
||||
final banner = await bannerFile.readAsString();
|
||||
|
||||
Reference in New Issue
Block a user