route_provider 4.5.3

Dart native
Flutter Android iOS

Provides backend routing for http-servers. Split routes into separates parts: authentification, controller for data processing and response for outputting the results.

dart-routeprovider #

Installation #

Add it to your dependencies

dependencies:
  route_provider: ^4.4.1

and install the package

$ pub get

Usage #

import 'dart:io';
import 'package:route_provider/route_provider.dart';
main() {
    Auth freeForAll = StaticAuth(authed: true);
    Auth userAuth = MyAuth();
    Responser jsonResponser = JsonResponse();
    HttpServer.bind(InternetAddress.anyIPv4,8080).then((HttpServer server){
        Router(server)
        ..route(
            url: '/',
            responser: FileResponse('docroot/index.html'),
            auth: freeForAll
        )
        ..route(
            url: '/assets/**',
            responser: FolderResponse('docroot/assets/'),
            auth: freeForAll
        )
        ..route(
            url: '/impress',
            responser: FileResponse('docroot/impress.html'),
            auth: freeForAll
        )
        ..route(
            url: '/api/data/:id',
            controller: DataRestApiController(),
            responser: jsonResponser,
            auth: userAuth
        )
        ..start();
    }).catchError((e) => print(e.toString()));
}

Contributing #

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Credits #

Robert Beyer 4sternrb@googlemail.com

License #

MIT

0
likes
80
pub points
66%
popularity

Provides backend routing for http-servers. Split routes into separates parts: authentification, controller for data processing and response for outputting the results.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

4sternrb@googlemail.com

License

MIT (LICENSE)

Dependencies

mime_type

More

Packages that depend on route_provider