Improve documentation details and score (#187)
* Improve documentation details and score
Fixes https://github.com/dart-lang/shelf/issues/177
Reference dart.dev docs
Reference related packages
Fix http:// URLs
Co-authored-by: Kathy Walrath <kathyw@google.com>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7f0efe0..ee94fc9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.1.4
+
+* Documentation improvements.
+
## 1.1.3
* Automatically remove `content-length` header from a `Response.notModified`.
diff --git a/README.md b/README.md
index 6388d91..04093a9 100644
--- a/README.md
+++ b/README.md
@@ -13,25 +13,34 @@
* Trivially mix and match synchronous and asynchronous processing.
* Flexibility to return a simple string or a byte stream with the same model.
+See the [Dart HTTP server documentation](https://dart.dev/tutorials/server/httpserver) for more
+information. You may also want to look at
+[package:shelf_router](https://pub.dev/packages/shelf_router) and
+[package:shelf_static](https://pub.dev/packages/shelf_static) as examples of
+packages that build on and extend `package:shelf`.
+
## Example
See `example/example.dart`
```dart
-import 'package:shelf/shelf.dart' as shelf;
-import 'package:shelf/shelf_io.dart' as io;
+import 'package:shelf/shelf.dart';
+import 'package:shelf/shelf_io.dart' as shelf_io;
-Future<void> main() async {
- var handler = const shelf.Pipeline().addMiddleware(shelf.logRequests())
- .addHandler(_echoRequest);
+void main() async {
+ var handler =
+ const Pipeline().addMiddleware(logRequests()).addHandler(_echoRequest);
- var server = await io.serve(handler, 'localhost', 8080);
+ var server = await shelf_io.serve(handler, 'localhost', 8080);
+
+ // Enable content compression
+ server.autoCompress = true;
+
print('Serving at http://${server.address.host}:${server.port}');
}
-shelf.Response _echoRequest(shelf.Request request) {
- return shelf.Response.ok('Request for "${request.url}"');
-}
+Response _echoRequest(Request request) =>
+ Response.ok('Request for "${request.url}"');
```
## Handlers and Middleware
@@ -188,8 +197,5 @@
## Inspiration
-* [Connect](http://www.senchalabs.org/connect/) for NodeJS.
- * Read [this great write-up](http://howtonode.org/connect-it) to understand
- the overall philosophy of all of these models.
-* [Rack](http://rack.github.io/) for Ruby.
-* [WSGI](http://legacy.python.org/dev/peps/pep-3333/) for Python.
+* [Connect](https://github.com/senchalabs/connect) for NodeJS.
+* [Rack](https://github.com/rack/rack) for Ruby.
diff --git a/example/example.dart b/example/example.dart
index 6d6beaf..dab0b1d 100644
--- a/example/example.dart
+++ b/example/example.dart
@@ -2,15 +2,14 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:shelf/shelf.dart' as shelf;
-import 'package:shelf/shelf_io.dart' as io;
+import 'package:shelf/shelf.dart';
+import 'package:shelf/shelf_io.dart' as shelf_io;
void main() async {
- var handler = const shelf.Pipeline()
- .addMiddleware(shelf.logRequests())
- .addHandler(_echoRequest);
+ var handler =
+ const Pipeline().addMiddleware(logRequests()).addHandler(_echoRequest);
- var server = await io.serve(handler, 'localhost', 8080);
+ var server = await shelf_io.serve(handler, 'localhost', 8080);
// Enable content compression
server.autoCompress = true;
@@ -18,6 +17,5 @@
print('Serving at http://${server.address.host}:${server.port}');
}
-shelf.Response _echoRequest(shelf.Request request) {
- return shelf.Response.ok('Request for "${request.url}"');
-}
+Response _echoRequest(Request request) =>
+ Response.ok('Request for "${request.url}"');
diff --git a/lib/src/util.dart b/lib/src/util.dart
index c2170fe..1c4d2c8 100644
--- a/lib/src/util.dart
+++ b/lib/src/util.dart
@@ -134,7 +134,7 @@
}
/// Multiple header values are joined with commas.
-/// See http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-21#page-22
+/// See https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p1-messaging-21#page-22
String? joinHeaderValues(List<String>? values) {
if (values == null) return null;
if (values.isEmpty) return '';
diff --git a/pubspec.yaml b/pubspec.yaml
index 54022e2..c8cc227 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: shelf
-version: 1.1.3
+version: 1.1.4
description: >-
A model for web server middleware that encourages composition and easy reuse
repository: https://github.com/dart-lang/shelf