This commit is contained in:
thosakwe 2016-12-21 12:51:43 -05:00
parent cb3430e233
commit 0ab637eb15
3 changed files with 9 additions and 13 deletions

View file

@ -1,6 +1,6 @@
# angel_static
![version 1.1.0-dev](https://img.shields.io/badge/version-1.1.0--dev-red.svg)
![version 1.1.0-dev+2](https://img.shields.io/badge/version-1.1.0--dev+2-red.svg)
![build status](https://travis-ci.org/angel-dart/static.svg?branch=master)
Static server middleware for Angel.
@ -11,7 +11,7 @@ In `pubspec.yaml`:
```yaml
dependencies:
angel_framework: ^1.0.0-dev
angel_static: ^1.1.0-dev+1
angel_static: ^1.1.0-dev
```
# Usage

View file

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_route/angel_route.dart';
import 'package:mime/mime.dart' show lookupMimeType;
final RegExp _param = new RegExp(r':([A-Za-z0-9_]+)(\((.+)\))?');
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
@ -56,12 +55,8 @@ class VirtualDirectory {
Future<bool> sendFile(File file, ResponseContext res) async {
_printDebug('Streaming file ${file.absolute.path}...');
res
..willCloseItself = true
..header(HttpHeaders.CONTENT_TYPE, lookupMimeType(file.path))
..status(200);
res.statusCode = 200;
await res.streamFile(file);
await res.io.close();
return false;
}

View file

@ -1,11 +1,12 @@
name: angel_static
description: Static server middleware for Angel.
environment:
sdk: ">=1.19.0"
homepage: https://github.com/angel-dart/angel_static
author: thosakwe <thosakwe@gmail.com>
version: 1.1.0-dev+1
version: 1.1.0-dev+2
dependencies:
angel_framework: ">=1.0.0-dev < 2.0.0"
mime: ">= 0.9.3 < 0.10.0"
angel_framework: ^1.0.0-dev
dev_dependencies:
http: ">= 0.11.3 < 0.12.0"
test: ">= 0.12.13 < 0.13.0"
http: ^0.11.3
test: ^0.12.13