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
As a developer, I want to be able to mount routes to a dynamic prefix so that I can have a consistent way to structure my router and apply middleware.
import'dart:io';
import'package:shelf/shelf.dart';
import'package:shelf/shelf_io.dart';
import'package:shelf_router/shelf_router.dart';
final _router =Router()..mount('/<echo>', (r) =>_echoHandler()(r));
Handler_echoHandler() {
var pipeline =constPipeline();
final router =Router()..get('/', (_) =>Response.ok('hi'));
return pipeline.addHandler(router);
}
voidmain(List<String> args) async {
final ip =InternetAddress.anyIPv4;
final handler =Pipeline().addMiddleware(logRequests()).addHandler(_router);
final port =int.parse(Platform.environment['PORT'] ??'8080');
final server =awaitserve(handler, ip, port);
print('Server listening on port ${server.port}');
}
I expect to be able to run the above server and make a GET request to http://localhost:8080/hello and get a 200 response with hi.
Instead, running the above code and making a GET request to http://localhost:8080/hello results in a 500 internal server error
ERROR - 2022-07-04 15:16:20.694525
GET /hello
Error thrown by handler.
RangeError (start): Invalid value: Not in inclusive range 0..5: 8
package:shelf/src/request.dart 258:20 Request.change
package:shelf_router/src/router.dart 163:32 Router.mount.<fn>
package:shelf_router/src/router_entry.dart 105:30 RouterEntry.invoke.<fn>
package:shelf_router/src/router_entry.dart 103:30 RouterEntry.invoke.<fn>
package:shelf_router/src/router_entry.dart 111:7 RouterEntry.invoke
package:shelf_router/src/router.dart 183:38 Router.call
As a developer, I want to be able to mount routes to a dynamic prefix so that I can have a consistent way to structure my router and apply middleware.
I expect to be able to run the above server and make a
GET
request tohttp://localhost:8080/hello
and get a 200 response withhi
.Instead, running the above code and making a GET request to
http://localhost:8080/hello
results in a 500 internal server errorRelated to google/dart-neats#40
The text was updated successfully, but these errors were encountered: