Git Product home page Git Product logo

dart-routeprovider's Introduction

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 [email protected]

License

MIT

dart-routeprovider's People

Contributors

4stern avatar gitter-badger avatar tvolkert avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dart-routeprovider's Issues

route definition improvement

defining routes only by url is not perfect, we must define more possibilities - url/path, method

from:

..route({
    "url": "/",
    "controller": new HomeController(),
    "response": new FileResponse("docroot/home.html")
})

to:

..route({
    "detect": {
        "path": "/",
        "method": "GET"
    },
    "controller": new HomeController(),
    "response": new FileResponse("docroot/home.html")
})

or multiple values:

..route({
    "detect": {
        "path": ["/", "/doc"],
        "method": ["GET", "POST"]
    },
    "controller": new HomeController(),
    "response": new FileResponse("docroot/home.html")
})

Interface for logging

We need logging informations about the state while runtime.
A abstract class defining the interface would be fine, so users kann define own loggers. Perhabs a console-logger and a file-logger will be delivered by us.

  • Interface
  • console-logger
  • file-logger

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.