Last updated:
0 purchases
shelf router
Web Request Router for Shelf #
Shelf makes it easy to build web
applications in Dart by composing request handlers. This package offers a
request router for Shelf, matching request to handlers using route patterns.
Also see the shelf_router_generator package
for how to automatically generate
a Route using the Route annotation in this package.
Example #
import 'package:shelf_router/shelf_router.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as io;
var app = Router();
app.get('/hello', (Request request) {
return Response.ok('hello-world');
});
app.get('/user/<user>', (Request request, String user) {
return Response.ok('hello $user');
});
var server = await io.serve(app, 'localhost', 8080);
copied to clipboard
See reference documentation of Router class for more information.
See also #
Package shelf for which this package can create routers.
Package shelf_router_generator which can generate
a router using source code annotations.
Third-party tutorial by creativebracket.com:
Video: Build RESTful Web APIs with shelf_router
Sample: repository for tutorial
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.