dia_router 0.0.2 copy "dia_router: ^0.0.2" to clipboard
dia_router: ^0.0.2 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!

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: #

  • dia - A simple dart http server in Koa2 style.

Plans: #

  • dia_cors - Package for CORS middleware. In progress.
  • 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.

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