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

Dart 1 only

**DEPREICATED: Mux is now integrated into jaguar package**. A isomorphic fluent route muxer for Jaguar

DEPREICATED: Mux is now integrated into jaguar package

jaguar_mux #

An isomorphic fluent route muxer for Jaguar

Example #

import 'package:jaguar/jaguar.dart';

main() async {
  final server = new Jaguar();

  // Get version route
  server.get('/api/version', (Context ctx) => 0.1);

  // Get info route
  server.get(
      '/api/info',
      (Context ctx) => Response.json({
            'name': 'jaguar',
            'motto': 'Speed. Simplicity. Extensiblity.',
            'degree of awesomeness': 'infinity!',
          }));

  // Shows show to decode JSON body from the request
  server.post('/api/math', (Context ctx) async {
    /// [bodyAsJsonMap] method on [Request] object can be used to decode JSON
    /// body of the request into Dart built-in object
    final Map body = await ctx.req.bodyAsJsonMap();
    final int a = body['a'];
    final int b = body['b'];

    return Response.json({
      'addition': a + b,
      'subtraction': a - b,
      'multiplication': a * b,
      'division': a ~/ b,
    });
  });

  await server.serve();
}
0
likes
10
pub points
0%
popularity

Publisher

unverified uploader

**DEPREICATED: Mux is now integrated into jaguar package**. A isomorphic fluent route muxer for Jaguar

Homepage

License

unknown (LICENSE)

Dependencies

jaguar, jaguar_reflect

More

Packages that depend on jaguar_mux