Perhaps some documentation would make things easier to understand.
When I try to combine this with dia_router the code won't run, see my attempt below.
import 'dart:io';
import 'package:dia/dia.dart' as dia;
import 'package:dia_router/dia_router.dart' as dia_router;
import 'package:dia_body/dia_body.dart';
/// Custom Context with Routing mixin
class ContextWithRouting extends dia.Context with dia_router.Routing, ParsedBody {
ContextWithRouting(HttpRequest request) : super(request);
}
main() async {
final app = dia.App((req)=>ContextWithRouting(req));
app.use(body());
final router = dia_router.Router('');
router.post('/', (ctx,next) async {
ctx.body = '''
query=${ctx.query}
parsed=${ctx.parsed}
files=${ctx.files}
''';
});
app.use(router.middleware);
await app.listen('0.0.0.0', 8080);
print('web server running');
}
post.dart:27:18: Error: The getter 'parsed' isn't defined for the class 'Routing'.
- 'Routing' is from 'package:dia_router/src/routing_mixin.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dia_router-0.1.6/lib/src/routing_mixin.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'parsed'.
parsed=${ctx.parsed}
^^^^^^
post.dart:28:17: Error: The getter 'files' isn't defined for the class 'Routing'.
- 'Routing' is from 'package:dia_router/src/routing_mixin.dart' ('../../.pub-cache/hosted/pub.dartlang.org/dia_router-0.1.6/lib/src/routing_mixin.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'files'.
files=${ctx.files}
Any help would be appreciated.