Default to build/web or web
This commit is contained in:
parent
9892f43749
commit
3bff493d36
2 changed files with 9 additions and 2 deletions
|
@ -5,7 +5,14 @@ import 'package:angel_framework/angel_framework.dart';
|
|||
import 'package:mime/mime.dart' show lookupMimeType;
|
||||
|
||||
/// Serves files statically from a given directory.
|
||||
Middleware serveStatic(Directory sourceDirectory) {
|
||||
Middleware serveStatic([Directory sourceDirectory]) {
|
||||
if (sourceDirectory == null) {
|
||||
String dirPath = Platform.environment['ANGEL_ENV'] == 'production'
|
||||
? './build/web'
|
||||
: './web';
|
||||
sourceDirectory = new Directory(dirPath);
|
||||
}
|
||||
|
||||
return (RequestContext req, ResponseContext res) async {
|
||||
String requested = req.path.replaceAll(new RegExp(r'^\/'), '');
|
||||
File file = new File.fromUri(
|
||||
|
|
|
@ -2,7 +2,7 @@ name: angel_static
|
|||
description: Static server middleware for Angel.
|
||||
homepage: https://github.com/angel-dart/angel_static
|
||||
author: thosakwe <thosakwe@gmail.com>
|
||||
version: 1.0.0-beta.1
|
||||
version: 1.0.0-beta.2
|
||||
dependencies:
|
||||
angel_framework: ">=0.0.0-dev < 0.1.0"
|
||||
mime: ">= 0.9.3 < 0.10.0"
|
||||
|
|
Loading…
Reference in a new issue