Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Dart HTTP webserver, providing server side session and routing and static file serving.
JavaScript Dart
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

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: (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);

                .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
                  new Route.withMatcher((req) => req.path.endsWith("someString"),  // matcher function returns bool
                   "customMatcherName",                                            // matcher name for logging
                   (req,res,data) => res.outputStream.write("Hello");              // execute on match
                .addEndpoint(new StaticFile("./public"));                // serve static files

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

  server.listen("", 8082); // start listening



  • Lots, especially tidy up CookieSession and StaticFile, and add Route.
  • Please treat all of this as pre-alpha.
  • It's not secure in the slightest, and the StaticFile handler alone will probably allow users to browse your pc!


  • CookieSession: sets a sessioncookie - just ported at the moment and not yet tested. Treat as pre-alpha.


  • Favicon: Serves a favicon from either the default ./favicon.ico or ./public/favicon.ico, or some specified location.
  • StaticFile: serves static files from the path provided in the constructor. Simply appends the request.uri onto whatever path you provide in, and tries to load it. Very insecure.
  • Route: executes a dart method in resposne to matching a path + method, or a matching function
Something went wrong with that request. Please try again.