Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: lib/src/server.dart

Issue 1411553006: Add a Server interface. (Closed) Base URL: git@github.com:dart-lang/shelf@master
Patch Set: Code review changes Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/io_server.dart ('k') | lib/src/server_handler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library shelf.server;
6
7 import 'dart:async';
8
9 import 'handler.dart';
10
11 /// An [adapter][] with a concrete URL.
12 ///
13 /// [adapter]: https://github.com/dart-lang/shelf#adapters
14 ///
15 /// The most basic definiton of "adapter" includes any function that passes
16 /// incoming requests to a [Handler] and passes its responses to some external
17 /// client. However, in practice, most adapters are also *servers*—that is,
18 /// they're serving requests that are made to a certain well-known URL.
19 ///
20 /// This interface represents those servers in a general way. It's useful for
21 /// writing code that needs to know its own URL without tightly coupling that
22 /// code to a single server implementation.
23 ///
24 /// There are two built-in implementations of this interface. You can create a
25 /// server backed by `dart:io` using [IOServer], or you can create a server
26 /// that's backed by a normal [Handler] using [ServerHandler].
27 ///
28 /// Implementations of this interface are responsible for ensuring that the
29 /// members work as documented.
30 abstract class Server {
31 /// The URL of the server.
32 ///
33 /// Requests to this URL or any URL beneath it are handled by the handler
34 /// passed to [mount]. If [mount] hasn't yet been called, the requests wait
35 /// until it is. If [close] has been called, [handler] will not be invoked;
36 /// otherwise, the behavior is implementation-dependent.
37 Uri get url;
38
39 /// Mounts [handler] as the base handler for this server.
40 ///
41 /// All requests to [url] or and URLs beneath it will be sent to [handler]
42 /// until [close] is called.
43 ///
44 /// Throws a [StateError] if there's already a handler mounted.
45 void mount(Handler handler);
46
47 /// Closes the server and returns a Future that completes when all resources
48 /// are released.
49 ///
50 /// Once this is called, no more requests will be passed to this server's
51 /// handler. Otherwise, the cleanup behavior is implementation-dependent.
52 Future close();
53 }
OLDNEW
« no previous file with comments | « lib/src/io_server.dart ('k') | lib/src/server_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698