dart-backend / angel

A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
https://github.com/dukefirehawk/angel
BSD 3-Clause "New" or "Revised" License
172 stars 21 forks source link

Bad State: No element at route request #93

Closed victor7w7r closed 1 year ago

victor7w7r commented 1 year ago

Hi, in my app i have a simple code for getting started

import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';

void main() async {
  var app = Angel();
  var http = AngelHttp(app);
  app.get("/", (req, res) => "Hello, world!");
  await http.startServer('localhost', 8080);
}

At request in the browser, the logger prints the next messages

Bad state: No element
dart:core                                             List.first
package:angel3_framework/src/core/driver.dart 128:24  Driver.handleRawRequest.<fn>.<fn>.handle.resolveTuple
package:angel3_framework/src/core/driver.dart 136:17  Driver.handleRawRequest.<fn>.<fn>.handle
dart:async                                            _CustomZone.run
package:angel3_framework/src/core/driver.dart 243:25  Driver.handleRawRequest.<fn>.<fn>

My Dart SDK is 2.18.6, I should ignore it? thank you for the pacience.

dukefirehawk commented 1 year ago

Can you try with Angel(reflector: MirrorsReflector()?

victor7w7r commented 1 year ago

Can you try with Angel(reflector: MirrorsReflector()?

Same error

import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';

@Expose('/controller')
class MyController extends Controller{

  @Expose('/')
  a() => "Hello, world!";
}

void main() async {

  //initializeReflectable();

  var app = Angel(reflector: MirrorsReflector());

  var http = AngelHttp(app);

  await app.mountController<MyController>();

  var server = await http.startServer();
  print("Angel server listening at ${http.uri}");
}
Bad state: No element 

Bad state: No element
dart:core                                             List.first
package:angel3_framework/src/core/driver.dart 128:24  Driver.handleRawRequest.<fn>.<fn>.handle.resolveTuple
package:angel3_framework/src/core/driver.dart 136:17  Driver.handleRawRequest.<fn>.<fn>.handle
dart:async                                            _CustomZone.run
package:angel3_framework/src/core/driver.dart 243:25  Driver.handleRawRequest.<fn>.<fn>
dukefirehawk commented 1 year ago

There is two ways to resolve this error

app.container.registerSingleton<MyController>(MyController());
await app.mountController<MyController>();

or

await app.configure(MyController().configureServer);

Internally it is calling registerSingleton and mountController.