shelf_gzip 1.0.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 67

shelf_gzip

Shelf middleware that compresses responses with GZIP

Usage

import 'dart:io';
import 'dart:async' show runZoned;
import 'package:path/path.dart' show join, dirname;
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as shelf_io;
import 'package:shelf_static/shelf_static.dart';
import 'package:shelf_gzip/shelf_gzip.dart';

void main() {
  // Assumes the server lives in bin/ and that `pub build` ran
  var pathToBuild =
      join(dirname(Platform.script.toFilePath()), '..', 'build/web');
  var staticHandler =
      createStaticHandler(pathToBuild, defaultDocument: 'index.html');

  var portEnv = Platform.environment['PORT'];
  var port = portEnv == null ? 9999 : int.parse(portEnv);

  runZoned(() async {
    var handler = const shelf.Pipeline()
        .addMiddleware(gzipMiddleware)
        .addHandler(staticHandler);

    await shelf_io.serve(handler, '0.0.0.0', port);

    print("Serving $pathToBuild on port $port");
  }, onError: (e, stackTrace) => print('Server error: $e $stackTrace'));
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

1.0.0

  • Initial version

Use this package as a library

1. Depend on it

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


dependencies:
  shelf_gzip: "^1.0.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


      import 'package:shelf_gzip/shelf_gzip.dart';
  
Version Uploaded Documentation Archive
1.0.0 Dec 13, 2016 Go to the documentation of shelf_gzip 1.0.0 Download shelf_gzip 1.0.0 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
64 / 100
Health:
Code health derived from static analysis. [more]
84 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
48 / 100
Overall score:
Weighted score of the above. [more]
67
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:shelf_gzip/shelf_gzip.dart with components: io.

Suggestions

  • Fix .analysis_options.

    We were unable to parse .analysis_options.

  • Package is getting outdated.

    The package was released 79 weeks ago.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use shelf_gzip.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 hints.

    Run dartfmt to format lib/shelf_gzip.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.

  • Enable strong mode analysis.

    Strong mode helps you to detect bugs and potential issues earlier.Start your analysis_options.yaml file with the following:

    analyzer:
      strong-mode: true
    

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0
shelf >=0.6.0 <0.7.0 0.6.8 0.7.3+1
Transitive dependencies
async 1.13.3 2.0.7
charcode 1.1.1
collection 1.14.10
http_parser 3.1.2
path 1.6.1
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.7+1
string_scanner 1.0.2
typed_data 1.1.5