dia_router 0.0.1 copy "dia_router: ^0.0.1" to clipboard
dia_router: ^0.0.1 copied to clipboard

outdated

A router for Dia. WARNING do not use it in production! It is alfa version and they need in more work!

example/dia_router_example.dart

import 'dart:io';

import 'package:dia/dia.dart';
import 'package:dia_router/dia_router.dart';

class ContextWithRouting extends Context with Routing {
  ContextWithRouting(HttpRequest request) : super(request);
}

void main() {
  /// create Dia app with Routing mixin on Context
  final app = App<ContextWithRouting>();

  /// create router and sub router
  final router1 = Router('/route');
  final router2 = Router('/subroute');

  /// add router middleware to app
  app.use(router1.middleware);

  /// add sub router middleware to router
  router1.use(router2.middleware);

  /// add hendler to GET request
  router2.get('/data/:id', (ctx, next) async {
    ctx.body = '${ctx.params}';
  });

  /// start server
  app
      .listen('localhost', 8080)
      .then((_) => print('Started on http://localhost:8080'));
}
1
likes
0
pub points
60%
popularity

Publisher

verified publisherawcoding.com

A router for Dia. WARNING do not use it in production! It is alfa version and they need in more work!

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dia, path_to_regexp

More

Packages that depend on dia_router