http_router 0.1.0 copy "http_router: ^0.1.0" to clipboard
http_router: ^0.1.0 copied to clipboard

outdatedDart 1 only

A simple http router

example/main.dart

import 'dart:io';
import 'dart:async';

import 'package:http_router/http_router.dart';

import './handlers/index.dart';
import './handlers/missing.dart';

main() {

  // bind the server to a host and port
  Future<HttpServer> server = HttpServer.bind("127.0.0.1", 3000);

  // whenever the server finishes binding
  server.then((HttpServer server) {

    // Initialize the router with specified vhosts and routes
    var httpRouter = new HttpRouter({
      'r:.*:3000': {
        'GET': {
          '/': new IndexHandler()
        }
      }
    }, new FallbackHandler());

    // pipe http requests to the http router
    server.pipe(httpRouter);

  });

}
0
likes
0
points
11
downloads

Publisher

unverified uploader

Weekly Downloads

A simple http router

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dictionary, option

More

Packages that depend on http_router