OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 final Map _servicePathMap = { | 6 final Map _servicePathMap = { |
7 'http' : { | 7 'http' : { |
8 'servers' : _httpServersServiceObject | 8 'servers' : _httpServersServiceObject |
| 9 }, |
| 10 'file' : { |
| 11 'randomaccessfiles' : _randomAccessFilesServiceObject |
9 } | 12 } |
10 }; | 13 }; |
11 | 14 |
12 String _serviceObjectHandler(List<String> paths, | 15 String _serviceObjectHandler(List<String> paths, |
13 List<String> keys, | 16 List<String> keys, |
14 List<String> values) { | 17 List<String> values) { |
15 assert(keys.length == values.length); | 18 assert(keys.length == values.length); |
16 badPath() { | 19 badPath() { |
17 throw "Invalid path '${paths.join("/")}'"; | 20 throw "Invalid path '${paths.join("/")}'"; |
18 } | 21 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 55 } |
53 return server._toJSON(false); | 56 return server._toJSON(false); |
54 } | 57 } |
55 return { | 58 return { |
56 'id': 'io/http/servers', | 59 'id': 'io/http/servers', |
57 'type': 'HttpServerList', | 60 'type': 'HttpServerList', |
58 'members': _HttpServer._servers.values | 61 'members': _HttpServer._servers.values |
59 .map((server) => server._toJSON(true)).toList(), | 62 .map((server) => server._toJSON(true)).toList(), |
60 }; | 63 }; |
61 } | 64 } |
| 65 |
| 66 Map _randomAccessFilesServiceObject(args) { |
| 67 if (args.length == 1) { |
| 68 var raf = _RandomAccessFile._files[int.parse(args.first)]; |
| 69 if (raf == null) { |
| 70 return {}; |
| 71 } |
| 72 return raf._toJSON(false); |
| 73 } |
| 74 return { |
| 75 'id': 'io/file/randomaccessfiles', |
| 76 'type': 'RandomAccessFileList', |
| 77 'members': _RandomAccessFile._files.values |
| 78 .map((raf) => raf._toJSON(true)).toList(), |
| 79 }; |
| 80 } |
| 81 |
OLD | NEW |