shelf_router_macro library

Experimental support for shelf_router using macros

This library provides a set of macros that can be used to define Router routes.

Example:

import 'package:data_class_macro/data_class_macro.dart';

@Controller()
class GreetingController {
  @Get('/<name>')
  Response greetingByName(Request request, String name) {
    return Response.ok('Hello, $name!');
  }
}

void main() async {
  final controller = GreetingController();
  unawaited(
    serve(controller.router, 'localhost', 8080),
  );
  print('✅ Server listening on http://localhost:8080/');

  print('🔍 Testing...');
  (await (await HttpClient().get('localhost', 8080, '/eeqk')).close())
      .transform(utf8.decoder)
      .listen(print); // Hello, eeqk!
}

See also:

Classes

Connect
A macro that in combination with Controller macro will register a route
Controller
A macro that marks class as a controller.
Delete
A macro that in combination with Controller macro will register a route
Get
A macro that in combination with Controller macro will register a route
A macro that in combination with Controller macro will register a route
Options
A macro that in combination with Controller macro will register a route
Patch
A macro that in combination with Controller macro will register a route
Post
A macro that in combination with Controller macro will register a route
Put
A macro that in combination with Controller macro will register a route
Trace
A macro that in combination with Controller macro will register a route