bliss 0.3.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 0

Bliss #

An easy to learn server side framework for Dart.

Purpose #

The purpose of this package is to be used internally at Indecks, but to also be extendable enough to be used in other projects. It can be used for serving static files and/or handling dynamic requests.

Usage #

A simple use case example:

import 'package:bliss/bliss.dart';

main() {
  new Server()
    ..setStaticHandler('web', defaults: ['index.html'])
    ..addHandler('GET', '/api/user/:id', (Map data) {
      Map user = {};
      // query database with `data['id']` and assign it to `user`
      return user;
    ..addHandler('POST', '/api/post', (Map postData, HttpRequest request) async {
      // store `postData` into database
      // add cookie to `request`

Planned Features #

  • [x] SSL support
  • [ ] Define specific codec for request payloads
  • [ ] WebSocket handlers

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Contribute #

Feel free to fork and make a pull request. Please stick to the Dart Style Guide

Changelog #

0.3.1 #

  • Strong mode compliant.

0.3.0 #

  • Support for hyphens in handler paths.
  • Can add custom headers to static handler.

0.2.1 #

  • Fixed server crash when accept-encoding header is not present on incoming HttpRequest.

0.2.0 #

  • The static handler now supports three more optional parameters;
    • cacheController: A function to determine the maximum duration for the browser to cache a static resource.
    • errorResponses: A map specifying what static resources to repond with when the server responds with a error code.
    • spaDefault: Added for the purpose of serving single page applications. If the server cannot find a resource and spaDefault is defined, it will respond with the spaDefault file instead and let the client handle the routing.

0.1.5 #

  • SSL support, setting the securityContext property will automatically bindSecure() on start().

0.1.2 #

  • Fixed Issue #1, can now leave Server constructor's parameters empty.

0.1.0 #

  • Create new Server object to set static handler and add dynamic handlers.

0.0.1 #

  • Initial version, created by Stagehand


library bliss.example;

import 'dart:async';

import 'package:bliss/bliss.dart';

void main() {
  new Server()
    ..setStaticHandler('web', cacheController: defaultCacheController)
    ..addHandler('get', '/api/:example', returnData)

    // Run the server to start listening for requests.

// You can use asynchronous function for the handler task's and it will await
// for the response.
Future returnData(data) async => data;

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  bliss: ^0.3.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:bliss/bliss.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0