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

Fast and extensible routing for the shelf ecosystem.

shelf_openrouter #

A fast and extensible router for the shelf ecosystem.

Features #

  • Better performance than shelf_router using a trie-like routing algorithm.
  • Similar api to shelf_router with some additional features.
  • Path parameters using the :param syntax.
  • Non-root catchall routes for a more flexible routing.
  • Registrations can be retrieved at runtime.

Getting Started #

Add the project to your pubspec.yaml file.

dependencies:
  shelf_openrouter: ^0.0.1

Usage #

Future<void> main() async {
  var app = ShelfOpenRouter();
  router.get("/api/v1/hello", (Request request) {
    return Response.ok("Hello");
  });
  router.get("/api/v1/hello/:name", (Request request, String name) {
    return Response.ok("Hello $name");
  });

  await shelf_io.serve(router.call, 'localhost', 8080);
}

Base Router #

If you want to integrate the base router into a framework that requires routing, you can use the OpenRouter class. The object stored using the router can be changed and has no restrictions on the type of object stored.

All route registrations can be retrieved after they have been added which makes it easier to generate openapi documentation.

(If you don't use shelf, just copy the router.dart file and use it as you see fit. This project uses the MIT-0 license, so you can do whatever you want with it.)

0
likes
140
pub points
0%
popularity

Publisher

verified publisherhelight.dev

Fast and extensible routing for the shelf ecosystem.

Repository (GitHub)
View/report issues

Topics

#shelf #routing #http

Documentation

API reference

License

MIT-0 (license)

Dependencies

shelf

More

Packages that depend on shelf_openrouter