Refactor range support implementation (#66)

Reduce nesting by extracting to a method allowing guard clauses and
inverted the conditionals with early returns. Remove some comments that
repeat the code. Use conditional map elements and `..[]` operator to
reduce the noise around setting headers.

Add tests for requests where the range header is ignored.
4 files changed
tree: 6dd7a4bd3d4c55f8507d14f0449c6a92c05cdc1e
  1. .github/
  2. .gitignore
  3. CHANGELOG.md
  4. CONTRIBUTING.md
  5. LICENSE
  6. README.md
  7. analysis_options.yaml
  8. example/
  9. lib/
  10. pubspec.yaml
  11. test/
README.md

shelf_static is a Handler for the Dart shelf package.

Build Status

Example

import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf_static/shelf_static.dart';

void main() {
  var handler = createStaticHandler('example/files', 
      defaultDocument: 'index.html');

  io.serve(handler, 'localhost', 8080);
}