jaguar_reflect 0.5.1 copy "jaguar_reflect: ^0.5.1" to clipboard
jaguar_reflect: ^0.5.1 copied to clipboard

outdatedDart 1 only

Reflection based alternative for Jaguar

jaguar_reflect #

Uses reflection instead of source generation to serve Jaguar Api classes

Usage #

A simple usage example:

final book = new Book.make('0', 'Book1', ['Author1', 'Author2']);

@Api(path: '/api/book')
class BooksApi {
  @Post()
  Future<Response<String>> addBook(Context ctx) async {
    // Decode request body as JSON Map
    final Map<String, dynamic> json = await ctx.req.bodyAsJsonMap();
    Book book = new Book()..fromMap(json);
    print(book.toMap());
    // Encode Map to JSON
    return Response.json(book.toMap());
  }
}

Future<Null> main(List<String> args) async {
  Jaguar jaguar = new Jaguar();
  jaguar.addApi(reflectJaguar(new BooksApi()));

  await jaguar.serve();
}
1
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Reflection based alternative for Jaguar

Homepage

License

unknown (LICENSE)

Dependencies

jaguar, quiver

More

Packages that depend on jaguar_reflect