dia_router 0.0.3 dia_router: ^0.0.3 copied to clipboard
A router for Dia. WARNING do not use it in production! It is alfa version and they need in more work!
Router middleware to Dia.
Middleware like as koa_router.
!!!WARNING!!! Not production ready!
Usage: #
A simple usage example:
import 'package:dia/dia.dart';
import 'package:dia_router/dia_router.dart';
/// Custom Context with Routing mixin
class ContextWithRouting extends Context with Routing {
ContextWithRouting(HttpRequest request) : super(request);
}
main() {
final app = dia.App<ContextWithRouting>();
final router = Router('/prefix');
router.get('/path/:id', (ctx,next) async {
ctx.body = 'params=${ctx.parsms} query=${ctx.query}';
});
app.use(router.middleware);
app
.listen('localhost', 8080)
.then((info) => print('Server started on http://localhost:8080'));
}
GET http://localhost:8080/perfix/path/12?count=10
params={id:12} query={count:10}
Router support all HTTP method: GET,POST,PUT,PATCH,OPTION,DELETE,HEADER,CONNECT,TRACE
For more details, please, see example folder && test folder.
Use with: #
Plans: #
- dia_body - Package to parse request body.
- dia_static - Package to serve static files.
Features and bugs: #
I will be glad for any help and feedback! Please file feature requests and bugs at the issue tracker.