サンプル
shelf 1.4.2: Handle and test shelf HTTP requests in Dart without binding a port, by building a Request and calling the router, middleware and handler directly
検証済みサンプル — pub shelf 1.4.2: Handle and test shelf HTTP requests in Dart without binding a port, by building a Request and calling the router, middleware and…
sha256:2651162215727e626baac2f69d7b7e043707968fea0f9218aa9dda0648549e95
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 2
- ビルドした署名鍵
- 2
宣言された環境
dart 3 linux x64 dart 3 dart pub
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| dart 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · pub@1 |
2026-08-14 |
| dart 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · pub@1 |
2026-08-18 |
ケース
HOW- ゴール
- Handle and test shelf HTTP requests in Dart without binding a port, by building a Request and calling the router, middleware and handler directly
- シンボル
-
- Router
- Router.routeNotFound
- Request.params
- Pipeline.addMiddleware
- Middleware
- Response.ok
- Message.readAsString
- Message.read
- Response.change
- Request.change
- 環境
- dart 3
- 作成日
- 2026-08-14T14:13:26Z
コントラクト
- assert a constructed Request driven straight through the Router dispatches on method and path with no port bound, that an unregistered method on a matched path is a 404 and not a 405, that a <param> stops at a slash, and that registering GET also registers a HEAD in front of it whose body is stripped but whose content-length still reports the GET body length
- assert a handler taking only a Request receives the captures through the request.params extension getter, backed by a shelf_router/params context key that survives request.change, and that params outside a Router is an empty unmodifiable map rather than null
- assert a handler taking extra arguments is filled positionally in route-pattern order with the closure's parameter names ignored, and that a wrong argument count is accepted at registration and fails as a NoSuchMethodError on the first matching request
- assert the unmatched route returns Router.routeNotFound itself, one shared instance that can be read more than once, that returning it from a handler resumes matching while an identical-looking Response.notFound ends the request, and that notFoundHandler replaces it
- assert Pipeline runs middleware in declaration order inbound and the reverse outbound, proven by a response header each middleware appends to and by one they overwrite where the outermost writer wins, and that middleware answering without calling the inner handler cuts out everything declared below it
- assert a shelf body is single-subscription whether it was passed as a String or as a Stream, that the second read throws StateError synchronously out of readAsString, and that change() shares the drained Body so only change(body: ...) restores it
- assert a logging middleware that reads the response body forwards an unreadable response, that the request-side version breaks the route handler through the router's own request.change, and that both are fixed by putting the read body back
- assert header lookup is case-insensitive on requests and responses while the stored keys keep the case they were written with, and that a request served over loopback arrives with lowercase keys because dart:io lowercases them off the wire
ファイル
- csx.json
- lib/api.dart
- pubspec.lock
- pubspec.yaml
- test/contract_test.dart