Crimsonhttp - http server for Dart

Crimson Dart Http middleware


Project maintained by chrisbu Hosted on GitHub Pages — Theme by mattgraham

CrimsonHttp server for Dart

Currently uses the chat sample http server, but will be ported to the dart:io http server once that is released

Loosely inspired upon sencha/connect for node.js

Makes use of log4dart, found here: https://github.com/Qalqo/log4dart (It expects to find log4dart in ../log4dart (ie, at the same level as crimson, not within the crimson folder structure).


Usage: See test/crimsonTest.dart for example, but it goes something like this...

main() {
  CrimsonHttpServer server = new CrimsonHttpServer();

  CrimsonModule sampleModule = new CrimsonModule(server);
  sampleModule.handlers
                .addEndpoint(new Favicon("./favicon.ico"))               //match the favicon request
                .addFilter(new CookieSession())                          //adds session support
                .addEndpoint(new Route("/hello","GET",(req,res,data) {   //execute arbitary code that matches a route
                   res.outputStream.write("Hello");
                ))         
                .addEndpoint(new StaticFile("./public"));                //serve static files

  server.modules["*"] = sampleModule;  //this is the default module.

  server.listen("127.0.0.1", 8082);

}

TODO

Filters

Endpoints